* [PATCH] KVM: SVM: Use 'unsigned long' for the physical address passed to VMSAVE
@ 2021-02-02 22:34 Sean Christopherson
2021-02-02 22:36 ` Sean Christopherson
2021-02-03 8:03 ` Paolo Bonzini
0 siblings, 2 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-02-02 22:34 UTC (permalink / raw)
To: Paolo Bonzini
Cc: Sean Christopherson, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel, kvm, linux-kernel, Robert Hu, Farrah Chen,
Danmei Wei, Tom Lendacky
Take an 'unsigned long' instead of 'hpa_t' in the recently added vmsave()
helper, as loading a 64-bit GPR isn't possible in 32-bit mode. This is
properly reflected in the SVM ISA, which explicitly states that VMSAVE,
VMLOAD, VMRUN, etc... consume rAX based on the effective address size.
Don't bother with a WARN to detect breakage on 32-bit KVM, the VMCB PA is
stored as an 'unsigned long', i.e. the bad address is long since gone.
Not to mention that a 32-bit kernel is completely hosed if alloc_page()
hands out pages in high memory.
Reported-by: kernel test robot <lkp@intel.com>
Cc: Robert Hu <robert.hu@intel.com>
Cc: Farrah Chen <farrah.chen@intel.com>
Cc: Danmei Wei <danmei.wei@intel.com>
Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/svm_ops.h | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/svm/svm_ops.h b/arch/x86/kvm/svm/svm_ops.h
index 0c8377aee52c..9f007bc8409a 100644
--- a/arch/x86/kvm/svm/svm_ops.h
+++ b/arch/x86/kvm/svm/svm_ops.h
@@ -51,7 +51,12 @@ static inline void invlpga(unsigned long addr, u32 asid)
svm_asm2(invlpga, "c"(asid), "a"(addr));
}
-static inline void vmsave(hpa_t pa)
+/*
+ * Despite being a physical address, the portion of rAX that is consumed by
+ * VMSAVE, VMLOAD, etc... is still controlled by the effective address size,
+ * hence 'unsigned long' instead of 'hpa_t'.
+ */
+static inline void vmsave(unsigned long pa)
{
svm_asm1(vmsave, "a" (pa), "memory");
}
--
2.30.0.365.g02bc693789-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: SVM: Use 'unsigned long' for the physical address passed to VMSAVE
2021-02-02 22:34 [PATCH] KVM: SVM: Use 'unsigned long' for the physical address passed to VMSAVE Sean Christopherson
@ 2021-02-02 22:36 ` Sean Christopherson
2021-02-03 8:03 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Sean Christopherson @ 2021-02-02 22:36 UTC (permalink / raw)
To: Paolo Bonzini, Vitaly Kuznetsov, Wanpeng Li, Jim Mattson,
Joerg Roedel, kvm, linux-kernel, Robert Hu, Farrah Chen,
Danmei Wei, Tom Lendacky
On Tue, Feb 02, 2021, Sean Christopherson wrote:
> Take an 'unsigned long' instead of 'hpa_t' in the recently added vmsave()
> helper, as loading a 64-bit GPR isn't possible in 32-bit mode. This is
> properly reflected in the SVM ISA, which explicitly states that VMSAVE,
> VMLOAD, VMRUN, etc... consume rAX based on the effective address size.
>
> Don't bother with a WARN to detect breakage on 32-bit KVM, the VMCB PA is
> stored as an 'unsigned long', i.e. the bad address is long since gone.
> Not to mention that a 32-bit kernel is completely hosed if alloc_page()
> hands out pages in high memory.
>
> Reported-by: kernel test robot <lkp@intel.com>
> Cc: Robert Hu <robert.hu@intel.com>
> Cc: Farrah Chen <farrah.chen@intel.com>
> Cc: Danmei Wei <danmei.wei@intel.com>
> Cc: Tom Lendacky <Thomas.Lendacky@amd.com>
> Signed-off-by: Sean Christopherson <seanjc@google.com>
Forgot got the Fixes tag. Or just squash this.
Fixes: f84a54c04540 ("KVM: SVM: Use asm goto to handle unexpected #UD on SVM instructions")
> ---
> arch/x86/kvm/svm/svm_ops.h | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm/svm_ops.h b/arch/x86/kvm/svm/svm_ops.h
> index 0c8377aee52c..9f007bc8409a 100644
> --- a/arch/x86/kvm/svm/svm_ops.h
> +++ b/arch/x86/kvm/svm/svm_ops.h
> @@ -51,7 +51,12 @@ static inline void invlpga(unsigned long addr, u32 asid)
> svm_asm2(invlpga, "c"(asid), "a"(addr));
> }
>
> -static inline void vmsave(hpa_t pa)
> +/*
> + * Despite being a physical address, the portion of rAX that is consumed by
> + * VMSAVE, VMLOAD, etc... is still controlled by the effective address size,
> + * hence 'unsigned long' instead of 'hpa_t'.
> + */
> +static inline void vmsave(unsigned long pa)
> {
> svm_asm1(vmsave, "a" (pa), "memory");
> }
> --
> 2.30.0.365.g02bc693789-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] KVM: SVM: Use 'unsigned long' for the physical address passed to VMSAVE
2021-02-02 22:34 [PATCH] KVM: SVM: Use 'unsigned long' for the physical address passed to VMSAVE Sean Christopherson
2021-02-02 22:36 ` Sean Christopherson
@ 2021-02-03 8:03 ` Paolo Bonzini
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2021-02-03 8:03 UTC (permalink / raw)
To: Sean Christopherson
Cc: Vitaly Kuznetsov, Wanpeng Li, Jim Mattson, Joerg Roedel, kvm,
linux-kernel, Robert Hu, Farrah Chen, Danmei Wei, Tom Lendacky
On 02/02/21 23:34, Sean Christopherson wrote:
> diff --git a/arch/x86/kvm/svm/svm_ops.h b/arch/x86/kvm/svm/svm_ops.h
> index 0c8377aee52c..9f007bc8409a 100644
> --- a/arch/x86/kvm/svm/svm_ops.h
> +++ b/arch/x86/kvm/svm/svm_ops.h
> @@ -51,7 +51,12 @@ static inline void invlpga(unsigned long addr, u32 asid)
> svm_asm2(invlpga, "c"(asid), "a"(addr));
> }
>
> -static inline void vmsave(hpa_t pa)
> +/*
> + * Despite being a physical address, the portion of rAX that is consumed by
> + * VMSAVE, VMLOAD, etc... is still controlled by the effective address size,
> + * hence 'unsigned long' instead of 'hpa_t'.
> + */
> +static inline void vmsave(unsigned long pa)
> {
> svm_asm1(vmsave, "a" (pa), "memory");
> }
> --
> 2.30.0.365.g02bc693789-goog
>
Squashed, thanks.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-02-03 8:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 22:34 [PATCH] KVM: SVM: Use 'unsigned long' for the physical address passed to VMSAVE Sean Christopherson
2021-02-02 22:36 ` Sean Christopherson
2021-02-03 8:03 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).