Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp424403pxb; Tue, 14 Sep 2021 00:05:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySCIf2zuW72sEbeWqtU1wZ+hnf9nWSlTEtTiMknDNOFgela65bwDOu5Bx+EEpGsrZSxduk X-Received: by 2002:a6b:8b4b:: with SMTP id n72mr12058656iod.18.1631603103246; Tue, 14 Sep 2021 00:05:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631603103; cv=none; d=google.com; s=arc-20160816; b=Nc0/ImDuAkKJDEF1fyzRjw4gp3raV+n/2NeVr98WwE7RRlgQWKoERQhy1kx7Y32e/g 3dTPzBfET8cDa9qEnuS8OQTSyJRFRe/pxeh4W/eviAlbh6aDSSmBMUxKx4rfSwUmWcgF xaOs1/yuW6AvjPQGJ7JytMQmIW6RW8X3em0eEfnj1GpSRHOKmJIU/I1dxlbE7iXKo8Hm FcfdQXg9JtQHw6TO/7xDzPasxPL8PFCpyQXuk5yVunP1WupDQWj2+t6CMgfgWeKkMf/L avruWrqNTpzN9N2GUMEbxVG33zduYvyZ+zO4UlG79pW8JxAwXVx6IOlsEwUBi5Hp5PZh Z35w== 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=DtVBH46SHKoKIwsFmytf76PwR5kg53yG9EF+y3kvUPg=; b=nfJNSxEq6m5rb0cvNYKUXNDTfiLzWQ/3cimEMDlNlc9kp0qxO8xKsDmO2DHu+hw0mF OVL+ExkOMfPjN54mtN/vuUvAkE2cJJUKBfrDqxe9uupIedIoxpaWFodFHxQN8Hq1jHq+ UYrxLaPb84Y3KvM1+O7lVh6KVfCy9B9HHbNHmmP0qIK7zFEL69r4J2mexdnHF08qMftC z3Es3D3xicM3ZgU4NH/dwgg2Ems70y7UEG+C5LJLg+jlAxfWzbiZCDBhZEerjwC8mn2M J+R4o7B5XEycsWQm9ySFbKTufQ0CkZfI8RvmwoXTFyWilFXbKriV0AWPTpg/wAJvaqrN wFDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DthXNV5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c39si8387839jaf.12.2021.09.14.00.04.51; Tue, 14 Sep 2021 00:05:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DthXNV5c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240447AbhINHFE (ORCPT + 99 others); Tue, 14 Sep 2021 03:05:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47984 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240277AbhINHFD (ORCPT ); Tue, 14 Sep 2021 03:05:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631603026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DtVBH46SHKoKIwsFmytf76PwR5kg53yG9EF+y3kvUPg=; b=DthXNV5cGt95UYpThJY7moAubnRqZpF90NWZdcn7y9BGDzviRbcqg55/5O6ouLxi27zrOf q8XgmCgxICqJ5j9iFnEe8CBLnyvYqQyoW7CNlC0sRbg9OQ57nQrVbl672zZrUfFxT3rDEw VN/wN2J7oVHzPy5Vxv9hc1ofR5cXiwg= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-4ia2939XPlm999h91LgA0A-1; Tue, 14 Sep 2021 03:03:44 -0400 X-MC-Unique: 4ia2939XPlm999h91LgA0A-1 Received: by mail-ed1-f72.google.com with SMTP id s12-20020a05640217cc00b003cde58450f1so6286754edy.9 for ; Tue, 14 Sep 2021 00:03:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=DtVBH46SHKoKIwsFmytf76PwR5kg53yG9EF+y3kvUPg=; b=W/HlfS92cgnCRwI5AEGR4ATNCLlLs2YSWK5DTunN4b67IExepAn6uYu0KD8Z7HZQV8 AHN5ey2mnihMcIb6UxKg2b+pVx67msFzCZzBSXyG8QRIHY9hXXRyNFZT36x9hlFwplt1 QSmrxdnnGe+r0iU7b7r6d9+bedOkVK/QLR1aT0hbTIT+7HOWUd2jJsURR9xoCqmdtyTh zEjzH+xyLJU+U+1xgI/JhFPkWgR6bUdYgxRyxyHiIZMeo6ExDLPRSSye5wy5UWx3kMIB apFsf6vmqyqYKi2uE1aVbUqf2M4kOUPR49Y1dC3O3CT6aoNMo3USTbZh+Ob2Ww/Vl0Lw fY+Q== X-Gm-Message-State: AOAM530cgjfXUu8SDgpNTDWr3+oKZ+pUlXrNugaaKx2Pe9bMqg9mDuDK MmgLxVgYmTZOXTwxyy3boTx/vRFnBBfD0ZbCgXQSzLeWDbvjZBxN137EgXRHZGk5PTT1AbWcaAC 7iFZTFJEPteD+Y9XuwsdQJwM/ X-Received: by 2002:a05:6402:b51:: with SMTP id bx17mr3708313edb.193.1631603023665; Tue, 14 Sep 2021 00:03:43 -0700 (PDT) X-Received: by 2002:a05:6402:b51:: with SMTP id bx17mr3708282edb.193.1631603023377; Tue, 14 Sep 2021 00:03:43 -0700 (PDT) Received: from gator.home (cst2-174-132.cust.vodafone.cz. [31.30.174.132]) by smtp.gmail.com with ESMTPSA id bq4sm4460079ejb.43.2021.09.14.00.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 00:03:42 -0700 (PDT) Date: Tue, 14 Sep 2021 09:03:40 +0200 From: Andrew Jones To: Raghavendra Rao Ananta Cc: Paolo Bonzini , Marc Zyngier , James Morse , Alexandru Elisei , Suzuki K Poulose , Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Subject: Re: [PATCH v6 09/14] KVM: arm64: selftests: Add guest support to get the vcpuid Message-ID: <20210914070340.u6fp5zo7pjpxdlga@gator.home> References: <20210913230955.156323-1-rananta@google.com> <20210913230955.156323-10-rananta@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210913230955.156323-10-rananta@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 13, 2021 at 11:09:50PM +0000, Raghavendra Rao Ananta wrote: > At times, such as when in the interrupt handler, the guest wants > to get the vcpuid that it's running on to pull the per-cpu private > data. As a result, introduce guest_get_vcpuid() that returns the > vcpuid of the calling vcpu. The interface is architecture > independent, but defined only for arm64 as of now. > > Suggested-by: Reiji Watanabe > Signed-off-by: Raghavendra Rao Ananta > Reviewed-by: Ricardo Koller > --- > tools/testing/selftests/kvm/include/kvm_util.h | 2 ++ > tools/testing/selftests/kvm/lib/aarch64/processor.c | 6 ++++++ > 2 files changed, 8 insertions(+) > > diff --git a/tools/testing/selftests/kvm/include/kvm_util.h b/tools/testing/selftests/kvm/include/kvm_util.h > index 010b59b13917..5770751a5735 100644 > --- a/tools/testing/selftests/kvm/include/kvm_util.h > +++ b/tools/testing/selftests/kvm/include/kvm_util.h > @@ -400,4 +400,6 @@ uint64_t get_ucall(struct kvm_vm *vm, uint32_t vcpu_id, struct ucall *uc); > int vm_get_stats_fd(struct kvm_vm *vm); > int vcpu_get_stats_fd(struct kvm_vm *vm, uint32_t vcpuid); > > +int guest_get_vcpuid(void); > + > #endif /* SELFTEST_KVM_UTIL_H */ > diff --git a/tools/testing/selftests/kvm/lib/aarch64/processor.c b/tools/testing/selftests/kvm/lib/aarch64/processor.c > index db64ee206064..f1255f44dad0 100644 > --- a/tools/testing/selftests/kvm/lib/aarch64/processor.c > +++ b/tools/testing/selftests/kvm/lib/aarch64/processor.c > @@ -277,6 +277,7 @@ void aarch64_vcpu_setup(struct kvm_vm *vm, int vcpuid, struct kvm_vcpu_init *ini x86's vcpu_setup strangely uses 'int' for vcpuid even though everywhere else we use uint32_t. Unfortunately that strangeness got inherited by aarch64 (my fault). We should change it to uint32_t here (as a separate patch) and... > set_reg(vm, vcpuid, KVM_ARM64_SYS_REG(SYS_TCR_EL1), tcr_el1); > set_reg(vm, vcpuid, KVM_ARM64_SYS_REG(SYS_MAIR_EL1), DEFAULT_MAIR_EL1); > set_reg(vm, vcpuid, KVM_ARM64_SYS_REG(SYS_TTBR0_EL1), vm->pgd); > + set_reg(vm, vcpuid, KVM_ARM64_SYS_REG(SYS_TPIDR_EL1), vcpuid); > } > > void vcpu_dump(FILE *stream, struct kvm_vm *vm, uint32_t vcpuid, uint8_t indent) > @@ -426,3 +427,8 @@ void vm_install_exception_handler(struct kvm_vm *vm, int vector, > assert(vector < VECTOR_NUM); > handlers->exception_handlers[vector][0] = handler; > } > + > +int guest_get_vcpuid(void) > +{ > + return read_sysreg(tpidr_el1); > +} ...return uint32_t here. Thanks, drew