From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 91F8D941D7A for ; Thu, 22 Feb 2024 16:14:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=9dM0DJBVA1zVZad+KmRxxf1spC2u7su9/vwCdbnPlG0=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:Autocrypt:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1708618444; v=1; b=lnrxR1n6/gw1WNMIONyUM2M3zOFkRilW3yWBJUQluyrmYUfwQooHxUvPdcN3F2UJquAbSGyr IBBX6rE7fJZmuvt+H0A99lRQFB015aNq8anBI3Pw3emNbxTm1f6ybI48QHQK3zhV/IpWvDk/szG e8AgA8cR6HbNJTkUdBYoQkVM= X-Received: by 127.0.0.2 with SMTP id Kt29YY7687511x3Qq7xMPjvB; Thu, 22 Feb 2024 08:14:04 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.16834.1708618443512246716 for ; Thu, 22 Feb 2024 08:14:03 -0800 X-Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-eF7hJi3NOLCvRESQJc33gg-1; Thu, 22 Feb 2024 11:14:00 -0500 X-MC-Unique: eF7hJi3NOLCvRESQJc33gg-1 X-Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-55fee28d93dso4137431a12.2 for ; Thu, 22 Feb 2024 08:14:00 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVEjQ2qyrTKJiLp7KZYNv2X/T9Aj/85F7conge4dFQPLO27XyDnQ8R48JlbaO+KjuBhyxbTvUVPlNagwF/cSX2w0e/t3A== X-Gm-Message-State: OXIZkrVlvNh9ZR1ZhSQT23Jyx7686176AA= X-Received: by 2002:a17:906:34c3:b0:a3e:b407:65ab with SMTP id h3-20020a17090634c300b00a3eb40765abmr7258645ejb.50.1708618439518; Thu, 22 Feb 2024 08:13:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IGtyO/27MDBL8vWagrKdCY0cP8bOKmNmTcuZ/tlQWX+kG5PdV88Ug6DrAffofQAAY2x5NVAZg== X-Received: by 2002:a17:906:34c3:b0:a3e:b407:65ab with SMTP id h3-20020a17090634c300b00a3eb40765abmr7258624ejb.50.1708618439127; Thu, 22 Feb 2024 08:13:59 -0800 (PST) X-Received: from ?IPV6:2001:b07:6468:f312:9af8:e5f5:7516:fa89? ([2001:b07:6468:f312:9af8:e5f5:7516:fa89]) by smtp.googlemail.com with ESMTPSA id vo7-20020a170907a80700b00a3d00616e1fsm2314912ejc.193.2024.02.22.08.13.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Feb 2024 08:13:58 -0800 (PST) Message-ID: <74a62ef0-bd0f-4844-985c-0035fc3d76f7@redhat.com> Date: Thu, 22 Feb 2024 17:13:57 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] GuestPhysAddrSize questions To: Tom Lendacky , Gerd Hoffmann , devel@edk2.groups.io Cc: Michael Roth , Jiewen Yao , Liming Gao , Laszlo Ersek , Ard Biesheuvel , Min Xu , Erdem Aktas , Oliver Steffen , Ard Biesheuvel References: <20240222105407.75735-1-kraxel@redhat.com> <20240222105407.75735-4-kraxel@redhat.com> <32oty4asp3xrecjruatwm77fbevcaizswovjc5jqct5bdofwiq@sgff2gzgau7o> From: "Paolo Bonzini" Autocrypt: addr=pbonzini@redhat.com; keydata= xsEhBFRCcBIBDqDGsz4K0zZ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MScIQtBAm0ihWPltXkyITA92ngCmPdHa6M1hMh4RDX+Jf1fiWubzp1voAg0 JBrdmNZSQDz0iKmSrx8xkoXYfA3bgtFN8WJH2xgFL28XnqY4M6dLhJwV3z08tPSRqYFm4NMP dRsn0/7oymhneL8RthIvjDDQ5ktUjMe8LtHr70OZE/TT88qvEdhiIVUogHdo4qBrk41+gGQh b906Dudw5YhTJFU3nC6bbF2nrLlB4C/XSiH76ZvqzV0Z/cAMBo5NF/w= In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pbonzini@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=lnrxR1n6; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 2/22/24 16:44, Tom Lendacky wrote: > On 2/22/24 05:24, Gerd Hoffmann wrote: >>    Hi, >> >>> +    if (Cr4.Bits.LA57) { >>> +      if (PhysBits > 48) { >>> +        /* >>> +         * Some Intel CPUs support 5-level paging, have more than 48 >>> +         * phys-bits but support only 4-level EPT, which effectively >>> +         * limits guest phys-bits to 48. >>> +         * >>> +         * AMD Processors have a different but somewhat related >>> +         * problem: They can handle guest phys-bits larger than 48 >>> +         * only in case the host runs in 5-level paging mode. >>> +         * >>> +         * Until we have some way to communicate that kind of >>> +         * limitations from hypervisor to guest, limit phys-bits >>> +         * to 48 unconditionally. >>> +         */ >> >> So I'm looking for some communication path.  One option would be to use >> some bits in the KVM cpuid leaves.  Another possible candidate is cpuid >> leaf 0x80000008. >> >>  From the AMD APM (revision 3.35): >> >>    CPUID Fn8000_0008_EAX Long Mode Size Identifiers >>    ------------------------------------------------ >> >>    The value returned in EAX provides information about the maximum host >>    and guest physical and linear address width (in bits) supported by the >>    processor. >> >>    Bits   FieldName        Description >> >>    31:24  —                Reserved >> >>    23:16 GuestPhysAddrSize Maximum guest physical address size in bits. >>                            This number applies only to guests using >> nested >>                            paging. When this field is zero, refer to the >>                            PhysAddrSize field for the maximum guest >>                            physical address size. See “Secure Virtual >>                            Machine” in APM Volume 2. >> >>    15:8  LinAddrSize       Maximum linear address size in bits. >> >>    7:0   PhysAddrSize      Maximum physical address size in bits. When >>                            GuestPhysAddrSize is zero, this field also >>                            indicates the maximum guest physical address >>                            size. >> >> The description of the GuestPhysAddrSize is somewhat vague.  Is this a >> value the hypervisor should use to figure how much address space it can >> give to guests?  Or is this a value the hypervisor can set to inform the >> guest about the available address space (which would be a solution to >> the problem outlined in the comment above)?  Or both? > > I believe the main purpose of GuestPhysAddrSize was for software use > (for nested virtualization) and that the hardware itself has always > returned zero for that value. So you should be able to use that field. > Adding @Paolo for his thoughts. I have already discussed this with Gerd, so I don't really have many thoughts to add. Anyhow, basically we would like GuestPhysAddrSize to be "redefined" as Maximum usable physical address size in bits. Physical addresses above this size should not be used, but will not produce a "reserved" page fault. When this field is zero, all bits up to PhysAddrSize are usable. This field is expected to be nonzero only on guests where the hypervisor is using nested paging. Also, to clarify the hardware behavior, if hCR4.LA57=0 and host PhysAddrSize==52, then will guest physical addresses above 2^48 1) cause a reserved #PF in the guest, or 2) cause a non-present NPF exit in the hypervisor? I remember that several years ago we had a discussion on hCR4.LA57=0 reducing the address space compared to MAXPHYADDR, but I cannot find the emails and also at the time I didn't notice GuestPhysAddrSize. Paolo -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115832): https://edk2.groups.io/g/devel/message/115832 Mute This Topic: https://groups.io/mt/104510523/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-