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: <ZTcCIPHMeX84auh-@google.com>
Date:   Mon, 23 Oct 2023 16:30:40 -0700
From:   Sean Christopherson <seanjc@...gle.com>
To:     Binbin Wu <binbin.wu@...ux.intel.com>
Cc:     kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
        pbonzini@...hat.com, chao.gao@...el.com, kai.huang@...el.com,
        David.Laight@...lab.com, robert.hu@...ux.intel.com,
        guang.zeng@...el.com
Subject: Re: [PATCH v11 08/16] KVM: x86: Introduce get_untagged_addr() in
 kvm_x86_ops and call it in emulator

On Wed, Sep 13, 2023, Binbin Wu wrote:
> Introduce a new interface get_untagged_addr() to kvm_x86_ops to untag
> the metadata from linear address.  Call the interface in linearization
> of instruction emulator for 64-bit mode.
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index ea48ba87dacf..e03313287816 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -8308,6 +8308,15 @@ static void emulator_vm_bugged(struct x86_emulate_ctxt *ctxt)
>  		kvm_vm_bugged(kvm);
>  }
>  
> +static gva_t emulator_get_untagged_addr(struct x86_emulate_ctxt *ctxt,
> +					gva_t addr, unsigned int flags)
> +{
> +	if (!kvm_x86_ops.get_untagged_addr)
> +		return addr;
> +
> +	return static_call(kvm_x86_get_untagged_addr)(emul_to_vcpu(ctxt), addr, flags);
> +}
> +
>  static const struct x86_emulate_ops emulate_ops = {
>  	.vm_bugged           = emulator_vm_bugged,
>  	.read_gpr            = emulator_read_gpr,
> @@ -8352,6 +8361,7 @@ static const struct x86_emulate_ops emulate_ops = {
>  	.leave_smm           = emulator_leave_smm,
>  	.triple_fault        = emulator_triple_fault,
>  	.set_xcr             = emulator_set_xcr,
> +	.get_untagged_addr   = emulator_get_untagged_addr,

Oh, and for posterity because I've now thought about this on two separate occasions:

We _could_ nullify .get_untagged_addr() if LAM isn't supported, e.g. to save a
RETPOLINE when applicable, but that would require making emulate_ops non-const,
and so I think it's worth eating the indirect call.  I suppose we could gate it
on CONFIG_ADDRESS_MASKING, but then we'd have to carry a bunch of #ifdefs in the
VMX code, so I don't think that's worth doing either.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ