From: Binbin Wu <binbin.wu@linux.intel.com>
To: yexun <yexun@linux.alibaba.com>
Cc: kvm@vger.kernel.org, chao.gao@intel.com, seanjc@google.com,
pbonzini@redhat.com
Subject: Re: [kvm-unit-tests PATCH v2] x86/lam: Allocate test page from AREA_LOW instead of AREA_NORMAL
Date: Tue, 2 Jun 2026 18:11:08 +0800 [thread overview]
Message-ID: <e565f91e-e41d-458b-939b-c2efe22111db@linux.intel.com> (raw)
In-Reply-To: <20260602060116.35206-1-yexun@linux.alibaba.com>
On 6/2/2026 2:01 PM, yexun wrote:
> The lam test does not set a guest memory size in x86/unittests.cfg, so
> QEMU falls back to the default of 128 MiB. AREA_NORMAL starts at PFN
> BIT(36-12), i.e. physical 64 GiB, which is never initialized in a
> 128 MiB guest. As a result, alloc_pages_flags(0, AREA_NORMAL) returns
> NULL and test_lam_user() ends up running its LAM checks against a NULL
> pointer, which is semantically meaningless even if the metadata-bit
> arithmetic happens to succeed.
>
> Allocate from AREA_LOW instead. AREA_LOW_PFN is BIT(24-12) (16 MiB),
> well within a 128 MiB guest, and bits 63..47 of the resulting linear
> address are still zero, so the LAM48/LAM57 metadata-bit checks remain
> valid. Update the adjacent comment accordingly.
>
> Fixes: 0164d7595c85 ("x86: Add test cases for LAM_{U48,U57}")
> Signed-off-by: yexun <yexun@linux.alibaba.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
> ---
> v2: assert vaddr instead of pfn
> v1: https://lore.kernel.org/all/20260601035401.39303-1-yexun@linux.alibaba.com/
>
> x86/lam.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/x86/lam.c b/x86/lam.c
> index 87efc5dd..33772ecb 100644
> --- a/x86/lam.c
> +++ b/x86/lam.c
> @@ -231,13 +231,13 @@ static void test_lam_user(void)
> bool has_lam = this_cpu_has(X86_FEATURE_LAM);
>
> /*
> - * The physical address of AREA_NORMAL is within 36 bits, so that using
> + * The physical address of AREA_LOW is within 36 bits, so that using
> * identical mapping, the linear address will be considered as user mode
> * address from the view of LAM, and the metadata bits are not used as
> * address for both LAM48 and LAM57.
> */
> - vaddr = alloc_pages_flags(0, AREA_NORMAL);
> - static_assert((AREA_NORMAL_PFN & GENMASK(63, 47)) == 0UL);
> + vaddr = alloc_pages_flags(0, AREA_LOW);
> + static_assert((vaddr & GENMASK(63, 47)) == 0UL);
>
> /*
> * Note, LAM doesn't have a global control bit to turn on/off LAM
prev parent reply other threads:[~2026-06-02 10:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 6:01 [kvm-unit-tests PATCH v2] x86/lam: Allocate test page from AREA_LOW instead of AREA_NORMAL yexun
2026-06-02 10:11 ` Binbin Wu [this message]
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=e565f91e-e41d-458b-939b-c2efe22111db@linux.intel.com \
--to=binbin.wu@linux.intel.com \
--cc=chao.gao@intel.com \
--cc=kvm@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=yexun@linux.alibaba.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.