From patchwork Tue Jan 26 14:11:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 12046751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 634EFC433DB for ; Tue, 26 Jan 2021 14:14:16 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2914322B3B for ; Tue, 26 Jan 2021 14:14:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2914322B3B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pdGNOQcFab3bGdVNnayK+l7php9dEvX3UwK4x/cKpHs=; b=Z08Bp+bzTBegvzN1kWFf3MvJB RroPlohPxGqqccgTkXWB1/BhvisqIQDACDUsuu60wm6AzeQDK2mrEOLf+2RTbrWYuuEOv0npYzjiw B6JZqvKLA6kgqEBg2Sqa14xMchmNcjMxZB0rqNNY7stb+DuVpcv2ahcEKibKzHoAZ+MJkkE0eALd8 P/xYM6qAPRwg7T9ehKYp/eIKyMAhH/OIOLDlWIe2bbnIClmcp3pIKJK8CViYMFGRS9zhX0kdCgK1V GpoakUdEaYUF6Ew8rxak/AH25BvakCNh99VpP3I5SffmhtbfWJsQuqJjwbmm7AsR3nt5PnBfkTHrM NpairR+YQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4P4x-0000QF-7d; Tue, 26 Jan 2021 14:12:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1l4P4k-0000N8-9l for linux-arm-kernel@lists.infradead.org; Tue, 26 Jan 2021 14:12:13 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 570BE11D4; Tue, 26 Jan 2021 06:12:05 -0800 (PST) Received: from monolith.localdoman (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 581B63F7D7; Tue, 26 Jan 2021 06:12:04 -0800 (PST) From: Alexandru Elisei To: maz@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH 2/2] KVM: arm64: vgic-v3: Rename VGIC_TO_MPIDR() to VGIC_TO_MPIDR_AFF() Date: Tue, 26 Jan 2021 14:11:56 +0000 Message-Id: <20210126141156.39317-3-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126141156.39317-1-alexandru.elisei@arm.com> References: <20210126141156.39317-1-alexandru.elisei@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210126_091210_505399_EBF1211D X-CRM114-Status: GOOD ( 14.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org GICv3 doesn't have an MPIDR register, but it uses the affinity fields from GICR_TYPER, which are also present in the MPIDR_EL1 register, to identify the Redistributor associated with a PE. The macro VGIC_TO_MPIDR() doesn't convert the affinity fields originating from an userspace ioctl into a valid MPIDR_EL1 value like its name would suggest (notably, the RES1 bit is missing); what it does is to shift the affinity fields to the same positions as the fields from the MPIDR_EL1 register. This value is then compared to the result of kvm_vcpu_get_mpidr_aff() to find the corresponding VCPU. Let's rename VGIC_TO_MPIDR() to VGIC_TO_MPIDR_AFF() to avoid any confusion about what the macro does. Signed-off-by: Alexandru Elisei --- arch/arm64/kvm/vgic/vgic-kvm-device.c | 12 ++++++------ arch/arm64/kvm/vgic/vgic.h | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-kvm-device.c b/arch/arm64/kvm/vgic/vgic-kvm-device.c index 44419679f91a..043eeb264ed8 100644 --- a/arch/arm64/kvm/vgic/vgic-kvm-device.c +++ b/arch/arm64/kvm/vgic/vgic-kvm-device.c @@ -473,18 +473,18 @@ struct kvm_device_ops kvm_arm_vgic_v2_ops = { int vgic_v3_parse_attr(struct kvm_device *dev, struct kvm_device_attr *attr, struct vgic_reg_attr *reg_attr) { - unsigned long vgic_mpidr, mpidr_reg; + unsigned long vgic_aff, mpidr_aff; /* * For KVM_DEV_ARM_VGIC_GRP_DIST_REGS group, - * attr might not hold MPIDR. Hence assume vcpu0. + * attr might not hold MPIDR affinity. Hence assume vcpu0. */ if (attr->group != KVM_DEV_ARM_VGIC_GRP_DIST_REGS) { - vgic_mpidr = (attr->attr & KVM_DEV_ARM_VGIC_V3_MPIDR_MASK) >> - KVM_DEV_ARM_VGIC_V3_MPIDR_SHIFT; + vgic_aff = (attr->attr & KVM_DEV_ARM_VGIC_V3_MPIDR_MASK) >> + KVM_DEV_ARM_VGIC_V3_MPIDR_SHIFT; - mpidr_reg = VGIC_TO_MPIDR(vgic_mpidr); - reg_attr->vcpu = kvm_mpidr_to_vcpu(dev->kvm, mpidr_reg); + mpidr_aff = VGIC_TO_MPIDR_AFF(vgic_aff); + reg_attr->vcpu = kvm_mpidr_to_vcpu(dev->kvm, mpidr_aff); } else { reg_attr->vcpu = kvm_get_vcpu(dev->kvm, 0); } diff --git a/arch/arm64/kvm/vgic/vgic.h b/arch/arm64/kvm/vgic/vgic.h index 64fcd7511110..66525b8e2aa4 100644 --- a/arch/arm64/kvm/vgic/vgic.h +++ b/arch/arm64/kvm/vgic/vgic.h @@ -34,12 +34,12 @@ /* * The Userspace encodes the affinity differently from the MPIDR, - * Below macro converts vgic userspace format to MPIDR reg format. + * Below macro converts vgic userspace format to MPIDR reg affinity format. */ -#define VGIC_TO_MPIDR(val) (VGIC_AFFINITY_LEVEL(val, 0) | \ - VGIC_AFFINITY_LEVEL(val, 1) | \ - VGIC_AFFINITY_LEVEL(val, 2) | \ - VGIC_AFFINITY_LEVEL(val, 3)) +#define VGIC_TO_MPIDR_AFF(val) (VGIC_AFFINITY_LEVEL(val, 0) | \ + VGIC_AFFINITY_LEVEL(val, 1) | \ + VGIC_AFFINITY_LEVEL(val, 2) | \ + VGIC_AFFINITY_LEVEL(val, 3)) /* * As per Documentation/virt/kvm/devices/arm-vgic-v3.rst,