lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0154963b-6bb5-fc33-6a29-bfa57f187c38@redhat.com>
Date:   Thu, 4 Nov 2021 19:50:36 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>, x86@...nel.org
Cc:     linux-kernel@...r.kernel.org, jpoimboe@...hat.com,
        mark.rutland@....com, dvyukov@...gle.com, seanjc@...gle.com,
        mbenes@...e.cz
Subject: Re: [RFC][PATCH 18/22] x86,kvm: Remove .fixup usage

On 11/4/21 17:47, Peter Zijlstra wrote:
> KVM instruction emulation has a gnarly hack where the .fixup does a
> return, luckily exceptions can easily emulate a return so create a new
> extable type to fully do the FASTOP magic.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> ---
>   arch/x86/include/asm/extable_fixup_types.h |    1 +
>   arch/x86/kvm/emulate.c                     |   14 +++-----------
>   arch/x86/mm/extable.c                      |   11 +++++++++++
>   3 files changed, 15 insertions(+), 11 deletions(-)
> 
> --- a/arch/x86/include/asm/extable_fixup_types.h
> +++ b/arch/x86/include/asm/extable_fixup_types.h
> @@ -40,5 +40,6 @@
>   #define	EX_TYPE_ONE_REG			(EX_TYPE_IMM_REG | EX_TYPE_IMM(1))
>   
>   #define	EX_TYPE_FAULT_SGX		18
> +#define	EX_TYPE_KVM_FASTOP		19
>   
>   #endif
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -344,7 +344,7 @@ static int fastop(struct x86_emulate_ctx
>   	__FOP_RET(#op "_" #dst)
>   
>   #define FOP1EEX(op,  dst) \
> -	FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception)
> +	FOP1E(op, dst) _ASM_EXTABLE_TYPE(10b, 10b, EX_TYPE_KVM_FASTOP)

There's a ret right after the 10b label, so I think you can just use this:

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 493511efa3dc..f382c03c5954 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -315,7 +315,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
  	__FOP_FUNC(#name)
  
  #define __FOP_RET(name) \
-	"ret \n\t" \
+	"11: ret \n\t" \
  	".size " name ", .-" name "\n\t"
  
  #define FOP_RET(name) \
@@ -344,7 +344,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
  	__FOP_RET(#op "_" #dst)
  
  #define FOP1EEX(op,  dst) \
-	FOP1E(op, dst) _ASM_EXTABLE(10b, kvm_fastop_exception)
+	FOP1E(op, dst) _ASM_EXTABLE_TYPE_REG(10b, 11b, EX_TYPE_ZERO_REG, %esi)
  
  #define FASTOP1(op) \
  	FOP_START(op) \

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ