lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e6dd174c-e6db-487e-8e0c-abb5bdf1b9b0@linux.intel.com>
Date: Wed, 21 Feb 2024 10:29:15 +0800
From: Binbin Wu <binbin.wu@...ux.intel.com>
To: Sagi Shahar <sagis@...gle.com>
Cc: linux-kselftest@...r.kernel.org, Ackerley Tng <ackerleytng@...gle.com>,
 Ryan Afranji <afranji@...gle.com>, Erdem Aktas <erdemaktas@...gle.com>,
 Isaku Yamahata <isaku.yamahata@...el.com>,
 Sean Christopherson <seanjc@...gle.com>, Paolo Bonzini
 <pbonzini@...hat.com>, Shuah Khan <shuah@...nel.org>,
 Peter Gonda <pgonda@...gle.com>, Haibo Xu <haibo1.xu@...el.com>,
 Chao Peng <chao.p.peng@...ux.intel.com>,
 Vishal Annapurve <vannapurve@...gle.com>, Roger Wang <runanwang@...gle.com>,
 Vipin Sharma <vipinsh@...gle.com>, jmattson@...gle.com, dmatlack@...gle.com,
 linux-kernel@...r.kernel.org, kvm@...r.kernel.org, linux-mm@...ck.org
Subject: Re: [RFC PATCH v5 03/29] KVM: selftests: Store initial stack address
 in struct kvm_vcpu



On 12/13/2023 4:46 AM, Sagi Shahar wrote:
> From: Ackerley Tng <ackerleytng@...gle.com>
>
> TDX guests' registers cannot be initialized directly using
> vcpu_regs_set(), hence the stack pointer needs to be initialized by
> the guest itself, running boot code beginning at the reset vector.
>
> We store the stack address as part of struct kvm_vcpu so that it can
> be accessible later to be passed to the boot code for rsp
> initialization.
>
> Signed-off-by: Ackerley Tng <ackerleytng@...gle.com>
> Signed-off-by: Ryan Afranji <afranji@...gle.com>
> Signed-off-by: Sagi Shahar <sagis@...gle.com>
> ---
>   tools/testing/selftests/kvm/include/kvm_util_base.h | 1 +
>   tools/testing/selftests/kvm/lib/x86_64/processor.c  | 4 +++-
>   2 files changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h
> index c2e5c5f25dfc..b353617fcdd1 100644
> --- a/tools/testing/selftests/kvm/include/kvm_util_base.h
> +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h
> @@ -68,6 +68,7 @@ struct kvm_vcpu {
>   	int fd;
>   	struct kvm_vm *vm;
>   	struct kvm_run *run;
> +	vm_vaddr_t initial_stack_addr;
>   #ifdef __x86_64__
>   	struct kvm_cpuid2 *cpuid;
>   #endif
> diff --git a/tools/testing/selftests/kvm/lib/x86_64/processor.c b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> index f130f78a4974..b6b9438e0a33 100644
> --- a/tools/testing/selftests/kvm/lib/x86_64/processor.c
> +++ b/tools/testing/selftests/kvm/lib/x86_64/processor.c
> @@ -621,10 +621,12 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id,
>   	vcpu_init_cpuid(vcpu, kvm_get_supported_cpuid());
>   	vcpu_setup(vm, vcpu);
>   
> +	vcpu->initial_stack_addr = stack_vaddr;
> +
>   	/* Setup guest general purpose registers */
>   	vcpu_regs_get(vcpu, &regs);
>   	regs.rflags = regs.rflags | 0x2;
> -	regs.rsp = stack_vaddr;
> +	regs.rsp = vcpu->initial_stack_addr;

Nit: No need to do this change.

Reviewed-by: Binbin Wu <binbin.wu@...ux.intel.com>

>   	regs.rip = (unsigned long) guest_code;
>   	vcpu_regs_set(vcpu, &regs);
>   


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ