From: Sean Christopherson <seanjc@google.com>
To: Gerd Hoffmann <kraxel@redhat.com>
Cc: kvm@vger.kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>,
"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] kvm/x86: reserve bit KVM_HINTS_PHYS_ADDRESS_SIZE_DATA_VALID
Date: Thu, 8 Sep 2022 14:52:36 +0000 [thread overview]
Message-ID: <YxoBtD+3sgEEiaFF@google.com> (raw)
In-Reply-To: <20220908114146.473630-1-kraxel@redhat.com>
On Thu, Sep 08, 2022, Gerd Hoffmann wrote:
> The KVM_HINTS_PHYS_ADDRESS_SIZE_DATA_VALID bit hints to the guest
> that the size of the physical address space as advertised by CPUID
> leaf 0x80000008 is actually valid and can be used.
>
> Unfortunately this is not the case today with qemu. Default behavior is
> to advertise 40 address bits (which I think comes from the very first x64
> opteron processors). There are lots of intel desktop processors around
> which support less than that (36 or 39 depending on age), and when trying
> to use the full 40 bit address space on those things go south quickly.
>
> This renders the physical address size information effectively useless
> for guests. This patch paves the way to fix that by adding a hint for
> the guest so it knows whenever the physical address size is usable or
> not.
>
> The plan for qemu is to set the bit when the physical address size is
> valid. That is the case when qemu is started with the host-phys-bits=on
> option set for the cpu. Eventually qemu can also flip the default for
> that option from off to on, unfortunately that isn't easy for backward
> compatibility reasons.
>
> The plan for the firmware is to check that bit and when it is set just
> query and use the available physical address space. When the bit is not
> set be conservative and try not exceed 36 bits (aka 64G) address space.
> The latter is what the firmware does today unconditionally.
>
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
> arch/x86/include/uapi/asm/kvm_para.h | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/include/uapi/asm/kvm_para.h b/arch/x86/include/uapi/asm/kvm_para.h
> index 6e64b27b2c1e..115bb34413cf 100644
> --- a/arch/x86/include/uapi/asm/kvm_para.h
> +++ b/arch/x86/include/uapi/asm/kvm_para.h
> @@ -37,7 +37,8 @@
> #define KVM_FEATURE_HC_MAP_GPA_RANGE 16
> #define KVM_FEATURE_MIGRATION_CONTROL 17
>
> -#define KVM_HINTS_REALTIME 0
> +#define KVM_HINTS_REALTIME 0
> +#define KVM_HINTS_PHYS_ADDRESS_SIZE_DATA_VALID 1
Why does KVM need to get involved? This is purely a userspace problem. E.g. why
not use QEMU's fw_cfg to communicate this information to the guest?
Defining this flag arguably breaks backwards compatibility for VMMs that already
accurately advertise MAXPHYADDR. The absence of the flag would imply that MAXPHYADDR
is invalid, which is not the case.
next prev parent reply other threads:[~2022-09-08 14:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-08 11:41 [PATCH] kvm/x86: reserve bit KVM_HINTS_PHYS_ADDRESS_SIZE_DATA_VALID Gerd Hoffmann
2022-09-08 14:52 ` Sean Christopherson [this message]
2022-09-09 5:02 ` Gerd Hoffmann
2022-09-09 9:02 ` Vitaly Kuznetsov
2022-09-09 14:53 ` Sean Christopherson
2022-09-13 9:40 ` Vitaly Kuznetsov
2022-09-21 13:42 ` Gerd Hoffmann
2022-09-21 15:00 ` Sean Christopherson
2022-09-21 16:32 ` Jim Mattson
2022-09-22 5:40 ` Xiaoyao Li
2022-09-22 12:24 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YxoBtD+3sgEEiaFF@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox