Re: [PATCH v5 1/4] KVM: selftests: Add KVM selftests header files for LoongArch

From: maobibo
Date: Wed Dec 13 2023 - 02:42:46 EST




On 2023/12/13 下午3:15, zhaotianrui wrote:


在 2023/12/13 上午1:18, Sean Christopherson 写道:
On Tue, Dec 12, 2023, zhaotianrui wrote:
Hi, Sean:

I want to change the definition of  DEFAULT_GUEST_TEST_MEM in the common
file "memstress.h", like this:

  /* Default guest test virtual memory offset */
+#ifndef DEFAULT_GUEST_TEST_MEM
  #define DEFAULT_GUEST_TEST_MEM        0xc0000000
+#endif

As this address should be re-defined in LoongArch headers.

Why?  E.g. is 0xc0000000 unconditionally reserved, not guaranteed to be valid,
something else?

So, do you have any suggesstion?

Hmm, I think ideally kvm_util_base.h would define a range of memory that can be
used by tests for arbitrary data.  Multiple tests use 0xc0000000, which is not
entirely arbitrary, i.e. it doesn't _need_ to be 0xc0000000, but 0xc0000000 is
convenient because it's 32-bit addressable and doesn't overlap reserved areas in
other architectures.
In general text entry address of user application on x86/arm64 Linux
is 0x200000, however on LoongArch system text entry address is strange, its value 0x120000000.

When DEFAULT_GUEST_TEST_MEM is defined as 0xc0000000, there is limitation for guest memory size, it cannot exceed 0x120000000 - 0xc000000 = 1.5G bytes, else there will be conflict. However
there is no such issue on x86/arm64, since 0xc0000000 is above text entry address 0x200000.

The LoongArch link scripts actually is strange, it brings out some compatible issues such dpdk/kvm selftest when user applications
want fixed virtual address space.

So here DEFAULT_GUEST_TEST_MEM is defined as 0x130000000 separately, maybe 0x140000000 is better since it is 1G super-page aligned for 4K page size.

Regards
Bibo Mao


Thanks for your explanation, and LoongArch want to define DEFAULT_GUEST_TEST_MEM to 0x130000000. As default base address for application loading is 0x120000000, DEFAULT_GUEST_TEST_MEM should be larger than app loading address, so that PER_VCPU_MEM_SIZE can be large enough, and kvm selftests app size is smaller than 256M in generic.

Thanks
Tianrui Zhao