Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5338700rdb; Wed, 13 Dec 2023 06:09:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGNTtniqTjzbOMP2YsJZzKvzPply1lYQb4R6uCNjVnTmdu+P8ZltgMhfzuShJBai0xWzNLG X-Received: by 2002:a17:90b:1c11:b0:288:4719:75c3 with SMTP id oc17-20020a17090b1c1100b00288471975c3mr3123436pjb.45.1702476546346; Wed, 13 Dec 2023 06:09:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702476546; cv=none; d=google.com; s=arc-20160816; b=kJYMrQC6MndxabQ5sURg9ylsAmfLb5ulkSB0jbsQo+dnCa03HahStPO11amUG4WT16 Neh9SgDTBMUvHjOzRApi9ssw+D67c6uNXksHc8fKqXFNtmrYF4vGRtkfnx+2S9YuTNdn swBsS4LM557LjoYAkNE+oLVCXXndtOSSLZIzUmMgysWQXBaDHP/RmAUzMnIZCaNfHwl4 vIjQ5pmCzD3UsOuDx0KoXzhj8cs+Tqf5JKFuJwY+b8ObF8RZiWEt/9P/xfdExp+3bHGE K3llDS0uUSV7IQvwUZyaRtNbh2l19k+bGIfuJxNZ4oxPOAGGxLelpCIoQ8rt2lckX1SL IcpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=w4lrG4sG6YQ4BIE8GkwyCjrSGGxi/UC5oCrLRkXbQKg=; fh=JVk7Rce+TEqrTDY98pTbTrwDDbwDXZ9yy8o+ntefm5U=; b=nd2ClMi7NHomuOfX0OcmmnRvwpqG2zDt6YDb/+rmUq2UmaarWWjcOc+4uCUZEI8Dse aZZVVsDtg7tPw4wo9o855bLhGXgCslXLXJJ189HPXplZXF0+hczjwHb3lucB0xvYE4nT PU7nBjpcgpAzZC5ltPozBmSjBnpasUcoDgvzOzpGZKjQnxROzvxlc7CedOAhI0ZQnsJB /tNfDEwvR9hUFdnyZiotS5rjXQTooUhRk9Wyiux5znsF4iNTNfhO4iwidpRFBUl9l/UK 8joGolc9duZKTd5/iFmS+2qrtAx3CvuP1DqW+gH23v0DIMfyFQ/iWM3L7Gar1c208CTT XOxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=YWJTIUaA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id s14-20020a17090ad48e00b0028af776869asi242230pju.86.2023.12.13.06.09.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:09:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=YWJTIUaA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id AFE0880C6E98; Wed, 13 Dec 2023 06:09:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1441802AbjLMOIr (ORCPT + 99 others); Wed, 13 Dec 2023 09:08:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233502AbjLMOIq (ORCPT ); Wed, 13 Dec 2023 09:08:46 -0500 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9EAA3EB for ; Wed, 13 Dec 2023 06:08:51 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-40c2db2ee28so73602275e9.2 for ; Wed, 13 Dec 2023 06:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1702476530; x=1703081330; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=w4lrG4sG6YQ4BIE8GkwyCjrSGGxi/UC5oCrLRkXbQKg=; b=YWJTIUaA6PxrUZacHC4Q0Oabi42NNKX04+vFLddIkUrNETTT+Z7dyOGhba9U2RWHb5 u5dJ7SDK6Sw8NIIorta1XjowuGg1EBaUjKZ30VyhW9Rx/NaHqaBEYnX/oq2GvuXDCu7l xeYQlxCCv1bZRCEG2Ur+f0dTNNnYQsfn8M7ah51MtsBOEhLczLGmpb1creprqmy5yZi/ wJsElLcFrbRTF/6HwR7VnS1t1mBhbXHhoH2cMS/K+bD0R2PFKvFc7y6axym75B6WbrJM aOwRfZ0c26RbUhPOsRydI7dtoevF14nUaTaCpbv8zt9ukf8RclqHs91U59aLh185FC3h yZjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702476530; x=1703081330; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=w4lrG4sG6YQ4BIE8GkwyCjrSGGxi/UC5oCrLRkXbQKg=; b=mnMWvOSIgelKe4/G0d96dEnWoklTATx2NnukitaPQ+mNHuea5Ovfv0MUGD0p+bW3mX xkdojrwcZyEWt9QfR2Prx2ScKSAhYzRicFVgo8RcNLnCWkejX0dE3sJjjy7Fy4awSPeI g2mNEJgipZfNIqdMLs0NC1hll6VU2UywLH7fy8thmY2ATzNASAFBfU3cVqCGRUZrZRaV Q45wcdqGSno7zYZYBqvy4gAABSp+NLQ/8bbgU6Wa+Gs/WDR5rN/ky/ZHxYrnrc35AMZt cw7CsaBF9stYvMPluwBQlAyAmVJloHWldC93car0kmPPdOj4H90YPw6NzmcDM3//pu6s sYnQ== X-Gm-Message-State: AOJu0YzgnJlGWWzf/uMo2pfdt4N42kfxP4fJEh/XTrUezk+e4FxmwT3l +X9R84p2oRpCEzno2AWmDh/Nlw== X-Received: by 2002:a05:600c:1d19:b0:40b:5e1d:83a0 with SMTP id l25-20020a05600c1d1900b0040b5e1d83a0mr4191978wms.52.1702476529934; Wed, 13 Dec 2023 06:08:49 -0800 (PST) Received: from localhost (2001-1ae9-1c2-4c00-20f-c6b4-1e57-7965.ip6.tmcz.cz. [2001:1ae9:1c2:4c00:20f:c6b4:1e57:7965]) by smtp.gmail.com with ESMTPSA id v6-20020a05600c444600b0040c46ba7b66sm11736461wmn.48.2023.12.13.06.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 06:08:49 -0800 (PST) Date: Wed, 13 Dec 2023 15:08:48 +0100 From: Andrew Jones To: Haibo Xu Cc: xiaobo55x@gmail.com, Paul Walmsley , Palmer Dabbelt , Albert Ou , Paolo Bonzini , Shuah Khan , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Zenghui Yu , Anup Patel , Atish Patra , Guo Ren , Conor Dooley , Mayuresh Chitale , Greentime Hu , wchen , Jisheng Zhang , Minda Chen , Samuel Holland , Sean Christopherson , Like Xu , Peter Xu , Vipin Sharma , Aaron Lewis , Thomas Huth , Maciej Wieczor-Retman , linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, kvm-riscv@lists.infradead.org Subject: Re: [PATCH v4 08/11] KVM: riscv: selftests: Add guest helper to get vcpu id Message-ID: <20231213-b02db86aaf7957be22b200f1@orel> References: <02f6c9ccaaeb4ceb67137863e0317f62cef62496.1702371136.git.haibo1.xu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02f6c9ccaaeb4ceb67137863e0317f62cef62496.1702371136.git.haibo1.xu@intel.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Dec 2023 06:09:01 -0800 (PST) On Tue, Dec 12, 2023 at 05:31:17PM +0800, Haibo Xu wrote: > Add guest_get_vcpuid() helper to simplify accessing to per-cpu > private data. The sscratch CSR was used to store the vcpu id. > > Signed-off-by: Haibo Xu > Reviewed-by: Andrew Jones > --- > tools/testing/selftests/kvm/include/aarch64/processor.h | 4 ---- > tools/testing/selftests/kvm/include/kvm_util_base.h | 9 +++++++++ > tools/testing/selftests/kvm/lib/riscv/processor.c | 8 ++++++++ > 3 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/tools/testing/selftests/kvm/include/aarch64/processor.h b/tools/testing/selftests/kvm/include/aarch64/processor.h > index c42d683102c7..16ae0ac01879 100644 > --- a/tools/testing/selftests/kvm/include/aarch64/processor.h > +++ b/tools/testing/selftests/kvm/include/aarch64/processor.h > @@ -226,8 +226,4 @@ void smccc_smc(uint32_t function_id, uint64_t arg0, uint64_t arg1, > uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, > uint64_t arg6, struct arm_smccc_res *res); > > - > - > -uint32_t guest_get_vcpuid(void); > - > #endif /* SELFTEST_KVM_PROCESSOR_H */ > diff --git a/tools/testing/selftests/kvm/include/kvm_util_base.h b/tools/testing/selftests/kvm/include/kvm_util_base.h > index a18db6a7b3cf..666438113d22 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util_base.h > +++ b/tools/testing/selftests/kvm/include/kvm_util_base.h > @@ -932,4 +932,13 @@ void kvm_selftest_arch_init(void); > > void kvm_arch_vm_post_create(struct kvm_vm *vm); > > +void vm_init_vector_tables(struct kvm_vm *vm); > +void vcpu_init_vector_tables(struct kvm_vcpu *vcpu); > + > +struct ex_regs; > +typedef void(*exception_handler_fn)(struct ex_regs *); > +void vm_install_exception_handler(struct kvm_vm *vm, int vector, exception_handler_fn handler); I think something happend on rebase since the above should be in a different patch (and were for v3). I suggest checking your previous and current version branches with git-range-diff after rebasing in order to catch stuff like this. Thanks, drew > + > +uint32_t guest_get_vcpuid(void); > + > #endif /* SELFTEST_KVM_UTIL_BASE_H */ > diff --git a/tools/testing/selftests/kvm/lib/riscv/processor.c b/tools/testing/selftests/kvm/lib/riscv/processor.c > index efd9ac4b0198..39a1e9902dec 100644 > --- a/tools/testing/selftests/kvm/lib/riscv/processor.c > +++ b/tools/testing/selftests/kvm/lib/riscv/processor.c > @@ -316,6 +316,9 @@ struct kvm_vcpu *vm_arch_vcpu_add(struct kvm_vm *vm, uint32_t vcpu_id, > vcpu_set_reg(vcpu, RISCV_CORE_REG(regs.sp), stack_vaddr + stack_size); > vcpu_set_reg(vcpu, RISCV_CORE_REG(regs.pc), (unsigned long)guest_code); > > + /* Setup sscratch for guest_get_vcpuid() */ > + vcpu_set_reg(vcpu, RISCV_CSR_REG(sscratch), vcpu_id); > + > /* Setup default exception vector of guest */ > vcpu_set_reg(vcpu, RISCV_CSR_REG(stvec), (unsigned long)guest_unexp_trap); > > @@ -436,3 +439,8 @@ void vm_install_interrupt_handler(struct kvm_vm *vm, exception_handler_fn handle > > handlers->exception_handlers[1][0] = handler; > } > + > +uint32_t guest_get_vcpuid(void) > +{ > + return csr_read(CSR_SSCRATCH); > +} > -- > 2.34.1 >