[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] x86/paging: restrict physical address width reported to guests
- To: Jan Beulich <jbeulich@xxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Mon, 18 Oct 2021 15:46:25 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=65CP0iUPtqia21TkFqKG7ZpQXC5syU2d8xVafPqoddg=; b=EahfrzCbOzj1vdEv5Lu+V4rreHly9xruxyqTO1tPALWIIyc94K25IGiCSN4WxBVjBpkZ5pBafSB2Pm99/pdMXyxU02Vqv7/H/bBwuyBj6yf+fO1kUEsUyq3+0lHdW9H4B54RBa+wn5ZQU9EAjpAOE7M/JzZr2AURZmd2iIY2Q3TgQmC9MjM6l+qD3LuA9OG/7n0HFsZ5iCYQmqP9S3LcFFgeIooTIxKrzzCDgkv+XQjn9cyjdhp0Kt4BPWyFMMcNq/+AFkZa29ySmhiw9nrgr5wJwZ8qi3kVp5eur1EUqxWvhLuLWvU2AS4SdNq00SfNMqAUuWAE5IpyFm7ABizyqg==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gWrYqM7RdU7q3Ftbt0/2E2XX5mPbEgdCNb9jbLxg8rIFOV3MenfOk8l91CwsOoCXo1cTfsK36PpXFUfWFI8o1+QiVhsmarkhpGrPwF/Mdzljy6uVIP/IbMHrZBKf9k3PWMok/uviHeduVA7JJ9E5VBPPybgPECAs4qTDkZ+SdlbEVWoQc8zY9xvfPPziUPV8lrZ0BRyJ2zFOXDcHNI24jZ+q2oGM7mcaihRLCDzp1HAz0v06CbNbXImd19y82DHEw+o1YMGv/5Qcg6ZKAqhUhWbE79Dqql+iH7rDWZOqagsCgCeeVrfSd/0fgiHVREsjKM/viDo2iKmNOl0U/dMIgw==
- Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
- Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 18 Oct 2021 13:47:09 +0000
- Ironport-data: A9a23:xbJQgaOdNLWhTpfvrR1+kMFynXyQoLVcMsEvi/4bfWQNrUpx1zABy mVMXWuPO6qCZ2L3eox0YY+0/R8PuZXdnNFkHQto+SlhQUwRpJueD7x1DKtR0wB+jCHnZBg6h ynLQoCYdKjYdpJYz/uUGuCJQUNUjMlkfZKhTr6ZUsxNbVU8En540Uszw7RRbrNA2rBVPSvc4 bsenOWHULOV82Yc3rU8sv/rRLtH5ZweiRtA1rAMTakjUGz2zhH5OKk3N6CpR0YUd6EPdgKMq 0Qv+5nilo/R109F5tpICd8XeGVSKlLZFVDmZna7x8FOK/WNz8A/+v9TCRYSVatYoxzRotx/0 oxHibixRCV4Z6rywt4MfDANRkmSPYUekFPGCX22sMjVxEzaaXr8hf5pCSnaP6VBpLwxWzsXs 6VFdnZdNXhvhMrvqF6/YvNrick5atHiIasUu216zCGfBvEjKXzGa/iXtYQFg2ht7ixINcyBQ 8kybzpxVTqeZSdPJFNUS84nk+j90xETdBUH8QnI9MLb+VP70whZwLXrdt3PdbSiVchT20qVu G/C12D4GQ0BcsySzyKf9XChjfOJmjn0MKoQHrCl8v9hgHWI23ceThYRUDOGTeKR0xDkHYgFc gpNp3Ro/fNaGFGXosfVdkWFrHCe5xQgf9tdMbxj7z/X8Lv7ylPMboQbdQJpZNsjvc4wYDUl0 F6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ud3AQV0gJ1XYJNu/xKDwOeOApP+tfKH LKjfA32QZINE5nIviTNz0gZazuttfLnJXpbVovAAMm0hCHiXeN5KThGxaV8x8CW3cXqI1Sv1 Ttokjc3OGOovu7whjT2yv66IlXosLozp9mCNaXgsYYBz3wgkKDZZhnWZeFoDcpydvfp2oCoZ 3pmVMNLs5z43TeciWcpgbs4RDp1HIU53rr2Taj8DDeiP28YAh/J9tKhIpffBecwVEnpstA3K VC2H/cn4ZLDDvb9R6NpOTgZlVPrA6ZsHAimekcgzh0So0FcoJcqoQZ4Qd8DIoAJiTn84oqed MeTP003MwmNG9yUkqp+lWGmLeXLzMO91a9Mwk/U/WuonprdCsT9Tpf+CQd9k1wvK7VBaM0vt gtn8xT5cZzp/QtHNdA7dE6MIKK41z2MGDx2V2pUCDa/YE8SjjwQs3MkfgIDN/DQu1/8HJ1ou WYbG9l
- Ironport-sdr: HgTPruBcWSkqA4o1ezVYNJNPUjaYaxGE3VuL/szeL3gCfG5PEyUkesteQa0CPLlxpceUUMBkze bkAsGlbZWTtw9wj5dEM8JMTdCqWKx5pLwkLTRQVrmEVz53eFyAudxYz/txm34bLtMQ8zF9eivy HJ0a0fPB9biLd8xYY0Wi7WWECUCr4rFPZZJCXUyiKWQClMRVsBxoCm5gyo6T4Mu6NtAl5isv+e WnUAkWisNT7c4Tnk9DBqfNkSUb0mcRUfPdTgM2wEfH00nXkqeEpzCEGkADROJoWftXHrPTPist GHvBoDhOabO4r4Z0IucXXBgg
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Wed, Sep 29, 2021 at 02:47:49PM +0200, Jan Beulich wrote:
> Modern hardware may report more than 48 bits of physical address width.
> For paging-external guests our P2M implementation does not cope with
> larger values. Telling the guest of more available bits means misleading
> it into perhaps trying to actually put some page there (like was e.g.
> intermediately done in OVMF for the shared info page).
>
> While there also convert the PV check to a paging-external one (which in
> our current code base are synonyms of one another anyway).
>
> Fixes: 5dbd60e16a1f ("x86/shadow: Correct guest behaviour when creating PTEs
> above maxphysaddr")
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
>
> --- a/xen/include/asm-x86/paging.h
> +++ b/xen/include/asm-x86/paging.h
> @@ -401,11 +401,18 @@ static always_inline unsigned int paging
> {
> unsigned int bits = paging_mode_hap(d) ? hap_paddr_bits : paddr_bits;
>
> - if ( !IS_ENABLED(CONFIG_BIGMEM) && paging_mode_shadow(d) &&
> - !is_pv_domain(d) )
> + if ( paging_mode_external(d) )
> {
> - /* Shadowed superpages store GFNs in 32-bit page_info fields. */
> - bits = min(bits, 32U + PAGE_SHIFT);
> + if ( !IS_ENABLED(CONFIG_BIGMEM) && paging_mode_shadow(d) )
> + {
> + /* Shadowed superpages store GFNs in 32-bit page_info fields. */
> + bits = min(bits, 32U + PAGE_SHIFT);
> + }
> + else
> + {
> + /* Both p2m-ept and p2m-pt only support 4-level page tables. */
> + bits = min(bits, 48U);
It would be nice if there was a way to not have to manually change the
values here if we ever support 5-level page tables for example, but I
don't know of any way.
Thanks, Roger.
|