Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1062784pxb; Tue, 14 Sep 2021 15:35:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwKNWdstKjlLSLqU8t2pLMu5EP8x3DLxr1LAhe6CHa9iBM68PuSmSjpxHLCTLS1/kubiiG X-Received: by 2002:a5e:dc02:: with SMTP id b2mr15813923iok.197.1631658942152; Tue, 14 Sep 2021 15:35:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631658942; cv=none; d=google.com; s=arc-20160816; b=nDIT0gCpWcKyopEgg6vIgALOTqeKeq/CV8QwS23xFAudSEszP9leDBxQy5YlVBwKe0 LRgwIIzQ5J9TDY3Ci6AYJanLyuE3y8fEgoxQAlQBx9Tc6nEfHgd7/1X6RoDqpOM23lja LN7IFX8cmE/CneAQm36afLivyE6QE/3j0OwRPlImFTZEjN1ZN3+xm/iT1nYxG2bOq4PQ eiA61RFLlduGESLpvnx9RmEl3JKXSwrTnTLWqMq3vQhABp30miQZIykiKRd02NWVIWjN b6uiZfqmFGjB6Jbyhba8/yQBYrE5+2wJveO6uvU8qaPEVbEynr9wVGeuKi8Hm57w5ynZ EqoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=BW7fBGcKsdrR8mke56V7bzU7gD9WyqlXvKOO1bey3dM=; b=lr9Daa0XT5VlRCUIhDRj3oRKWdn9NTBemghM/G39VR7Pw+W6TP/17vJ0OXHZ5t9c6U Lf61EgiYk39J4tNP0coMr1ypsi6/4lwgDKX3buTi1B+usH1DLDSxsLt3r8zq53jZiBMH vjlxOPhi3/8MzcXElW11d+gSnuDQ5WuOZvyrg796sqS0utWVEcDSMA6XW9+oz8wsWHjX thZHzUtiSNy/5lislhXRYzO0GShy2vuA4IhF35ISIowemVcguF+u3GqJABjjctYraEmt VXVbeZoF8Xxw0pM7Kxy4AKhNsaTG1wNN4mYJcmQaiahGHOU+EzM9un2aArqpwmBNoiOD mvFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=KKrMidev; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s1si12113821jaj.97.2021.09.14.15.35.31; Tue, 14 Sep 2021 15:35:42 -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=@google.com header.s=20210112 header.b=KKrMidev; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236019AbhINWe3 (ORCPT + 99 others); Tue, 14 Sep 2021 18:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235952AbhINWdG (ORCPT ); Tue, 14 Sep 2021 18:33:06 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69CDFC0613E0 for ; Tue, 14 Sep 2021 15:31:45 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id l11-20020a056902072b00b005a776eefb28so969936ybt.5 for ; Tue, 14 Sep 2021 15:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=BW7fBGcKsdrR8mke56V7bzU7gD9WyqlXvKOO1bey3dM=; b=KKrMidevVqRU8tnCf4HU4OhnmV4gTubXrbIfa7ytYE6gg6NnqwIA73O/SeJOdKPaFS +aF6f8SR1NWh9ctn4JkR57SOSgLADPbjUTJXnTPMlWXteaQen7oI9433NcrMbrU9+6Vx IfOmq44ELPlXjNG5vZ8UGDbY8XrQNygpDmddOehD8XpaTdhS5CBvPXhFs97WUdE3mdlx +rlcewue0YSfqo1HwOKvI4mzWUA4vf5jcotMRA3l3ydvvLj8mozJhget75ThKDippFOI QQYqdf3SRHPJwf8tlda7NBau1BdAqms2EsS0QX+etXuBOJJaFOw6OK7Ykj4paUtyEafI le9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BW7fBGcKsdrR8mke56V7bzU7gD9WyqlXvKOO1bey3dM=; b=0Pby/laDSzR1V/ttT/sjSrv9Fz7Jh9QZz+Xyg1tt0tYl8lSmKC9Cc6Zf2sZiD+aosW QrGaMbm1mFbV+I5812gm5tUhDnu5f9INVVbKUx23r2RDbrycboXhRa1J4rVkrPaXe4Wh oEcgYSyKq4wdorlObxkbYNKUQalXSUFlInhiiele8pGVhvuAcOrVlzU66qs4CYuxE1Tx 4BWZafVLHangqGAAcmNy/HhaiC7KCsot/BZUSkFxZFZ8oGdt+WNbI0E7Ba50ATZULuYV dD77DpXmRE+jlc8NnH/9us1BWixLQIvG/7zu8vyDmUjFSFo+LkFPP9BQSChfGrLpJfav yFXQ== X-Gm-Message-State: AOAM533nztJLzeNVJh1XRds5JnzsqAb8psVDTyFBp1iPDnd4kjDFm3JJ XioyHmzyNsMOIXqbM1FUFjGd1q+OV3Gp X-Received: from rananta-virt.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:1bcc]) (user=rananta job=sendgmr) by 2002:a25:5607:: with SMTP id k7mr2077562ybb.378.1631658704625; Tue, 14 Sep 2021 15:31:44 -0700 (PDT) Date: Tue, 14 Sep 2021 22:31:09 +0000 In-Reply-To: <20210914223114.435273-1-rananta@google.com> Message-Id: <20210914223114.435273-11-rananta@google.com> Mime-Version: 1.0 References: <20210914223114.435273-1-rananta@google.com> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog Subject: [PATCH v7 10/15] KVM: arm64: selftests: Add guest support to get the vcpuid From: Raghavendra Rao Ananta To: Paolo Bonzini , Marc Zyngier , Andrew Jones , James Morse , Alexandru Elisei , Suzuki K Poulose Cc: Catalin Marinas , Will Deacon , Peter Shier , Ricardo Koller , Oliver Upton , Reiji Watanabe , Jing Zhang , Raghavendra Rao Anata , linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Reviewed-by: Reiji Watanabe --- 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..bcf05f5381ed 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); +uint32_t 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 34f6bd47661f..b4eeeafd2a70 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, uint32_t vcpuid, struct kvm_vcpu_init 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; } + +uint32_t guest_get_vcpuid(void) +{ + return read_sysreg(tpidr_el1); +} -- 2.33.0.309.g3052b89438-goog