On 2/16/22 08:19, Gerd Hoffmann wrote: > On Tue, Feb 15, 2022 at 07:37:40PM +0000, Joao Martins wrote: >> On 2/15/22 09:53, Gerd Hoffmann wrote: >>> What is missing: >>> >>> * Some way for the firmware to get a phys-bits value it can actually >>> use. One possible way would be to have a paravirtual bit somewhere >>> telling whenever host-phys-bits is enabled or not. >>> >> If we are not talking about *very old* processors... isn't what already >> advertised in CPUID.80000008 EAX enough? That's the maxphysaddr width >> on x86, which on qemu we do set it with the phys-bits value; > > Sigh. Nope. Did you read the complete reply? > Yes, I did.
What I overlooked was the emphasis you had on desktops (qemu default bigger than host-advertised), where I am thinking mostly in servers. > Problem is this is not reliable. With host-phys-bits=off (default) qemu > allows to set phys-bits to whatever value you want, including values > larger than what the host actually supports. Which renders > CPUID.80000008.EAX unusable. I am seeing from another angle, which the way to convey the phys-bits is via this CPUID leaf is *maybe* enough (like real hardware). But we are setting with a bigger value than we should have (or in other words ... not honoring our physical boundary). > To make things even worse: The default > value (phys-bits=40) is larger than what many intel boxes support. > > host-phys-bits=on fixes that. It makes guest-phys-bits == host-phys-bits > by default, and also enforces guest-phys-bits <= host-phys-bits. > So with host-phys-bits=on the guest can actually use CPUID.80000008.EAX > to figure how big the guest physical address space is. > Your 2 paragraphs sound like it's two different things, but +host-phys-bits just sets CPUID.80000008.EAX with the host CPUID equivalent leaf/register value. Which yes, it makes it reliable, but the way to convey is still the same. That is regardless, of phys-bits=bogus-bigger-than-host-number, host-phys-bits=on or host-phys-bits-limit=N. > Problem is the guest doesn't know whenever host-phys-bits is enabled or > not ... > > So the options to fix that are: > > (1) Make the host-phys-bits option visible to the guest (as suggested > above), or > (2) Advertise a _reliable_ phys-bits value to the guest somehow. What I am not enterily sure from (1) is the value on having a 'guest phys-bits' and a 'host phys-bits' *exposed to the guest* when it seems we are picking the wrong value for guests. It seems unnecessary redirection (compared to real hw) unless there's a use-case in keeping both that I am probably missing. Joao