From patchwork Thu Jan 12 14:03:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 42455 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3897838wrt; Thu, 12 Jan 2023 06:05:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXsroTOORqy+ULdBa0QR1TPsH8uPFgGBxbznHDBjR7Hzo2Zrq1erzU4vwbD19SEyCbTitXr+ X-Received: by 2002:a05:6a21:3996:b0:ad:2abb:5a5b with SMTP id ad22-20020a056a21399600b000ad2abb5a5bmr93219991pzc.9.1673532356269; Thu, 12 Jan 2023 06:05:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673532356; cv=none; d=google.com; s=arc-20160816; b=AkFpvXv6OGBt/LxueDofGkAVQ9y20if042rbXikxNa96PhXaccRTWrgNtToN8iaVGa q7X1ErHvLIE/rFVW2MCbPSdXf72EvXfTpoyFNwNP2zw6bkDDIx0V3rcxKR3yTVmVRGU4 WFaiapwgPHKhJPDDqlwJV9/zTpPFd5vTdAgJ0cOdeuSfoe/KRCNKSZp3crv437dJnVNR Q1b9kr3kjLQzW0j34ha3r8FsdxAPEAwvS4I3RERQrXHTjIs7D4IvY4DcvBQe9zwu8Yiy KsHz+Pn9zS1m54lVDe5t0S1nkLd3s4kBbwoRU1r/9Jz7GRAXJV2WEo3+Hi/dqKPy7Pxd NdNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=41mwjRtAV9Ps8+RICLlcEu1Jp8E7xzwVnsOTMb697U8=; b=wJOanAXT2Z0ZCQ+uJeArDc7B6itC2QyO4aKeyYfU3gAPGRQmUjcAnlKAsa6JpduX63 MlPui7svHkRqRze4k1/vqv/couFIExBe5xFtQM0PT/f8Cr7051vqzeT9nfbLhkejLfIR aaMD52ijRcv+SRhHr5BOMSvc9Mmyaujc5nz6OjPqvNpJLYGNH+7M/I7v7xo/i75AVdX2 QSRaGbagpzEE/0vogo6vj0Js5DiW+vHAKRkmA1Dk2wVfwK0a2FsosFxdNjnse8gxs2Bx 3LDwfgQa4mYrYPf0lErX9wUv0DZ4GisE1CJAUfgwHHKX5hvscn7SqjvnabQpWRlbTO+4 NQkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Cx9wgXiG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u37-20020a631425000000b0046e9babe7a1si17824847pgl.54.2023.01.12.06.05.39; Thu, 12 Jan 2023 06:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=Cx9wgXiG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234248AbjALOED (ORCPT + 99 others); Thu, 12 Jan 2023 09:04:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234650AbjALODn (ORCPT ); Thu, 12 Jan 2023 09:03:43 -0500 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 544385132E for ; Thu, 12 Jan 2023 06:03:40 -0800 (PST) Received: by mail-pj1-x1029.google.com with SMTP id o7-20020a17090a0a0700b00226c9b82c3aso20961864pjo.3 for ; Thu, 12 Jan 2023 06:03:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=41mwjRtAV9Ps8+RICLlcEu1Jp8E7xzwVnsOTMb697U8=; b=Cx9wgXiG3yGJIP13AxtRLpEyPm0oHQsEnGUEH13SkW0zvi6xNemz4LlDlYS9AOoc6E 3CHh1eoF1q5fDipXLRzUd5Ecg06hisNoF/bGEbx5ujjl5KvD1iOskHMzb/dkc63SsYQy H5mzf4RXtvetFCoBGo/S/MSYHSTLohsQ7hvwjGUGq37fBrZZlw+bEyB9p5P6s4s1lxa4 uyXKOhwk5Y5EVjbGWtYFn5aNcpmNCQG1BOL2WjHYGCW43O32Pv4blj6GahAXGHgQwKGR 6w0BzQUpAycWFRh1dU5nk3k6mkW0qLJkvte40xai5RWIQi1R81H+MT6k9LUmDVe3gvdF 8k9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=41mwjRtAV9Ps8+RICLlcEu1Jp8E7xzwVnsOTMb697U8=; b=crtrUvknz8gYLcoTaUmdr+JGvTU6le7jPmNHZnKRvxQfUl3g+CI4XMwoovOM24/yB3 HerzJyGROEvB4GY8MPsWo/CnKfyoccM8KdfA5BcKPsth4S0AV4xoP2fEwDJ3igEZEfYD p5AL47hyjGgoy7Q/xuS9emXGmCw+P6F4rULVPefPFBuLAfP+e+QCkW3afelJ2TVJ5tK/ E1Mk0BdUUTwG1c4aMa6IV2A7xgf/0yir8NM9XGhEURQUiLV6LD1LZA36MEMDTK198nyJ JEXWm0B5v2ObsgkJqoL1nkeGu1DuGjqxQ7lv82aWUetC6madXhm7yCq7KDsAoqdnTDbt UNdw== X-Gm-Message-State: AFqh2kpMEqAcmrvhwaWu8PHutQ/e/67+ZqnzlgyrOky2H3prow3kBTxc bCpjI0gH9J8A/ssZUhgmd+HEwQ== X-Received: by 2002:a17:902:8543:b0:192:9454:7b32 with SMTP id d3-20020a170902854300b0019294547b32mr48252741plo.40.1673532219874; Thu, 12 Jan 2023 06:03:39 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id d11-20020a170902cecb00b001925016e34bsm12351455plg.79.2023.01.12.06.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 06:03:39 -0800 (PST) From: Anup Patel To: Paolo Bonzini , Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Andrew Jones , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH 3/7] RISC-V: KVM: Drop the _MASK suffix from hgatp.VMID mask defines Date: Thu, 12 Jan 2023 19:33:00 +0530 Message-Id: <20230112140304.1830648-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230112140304.1830648-1-apatel@ventanamicro.com> References: <20230112140304.1830648-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754825864239055553?= X-GMAIL-MSGID: =?utf-8?q?1754825864239055553?= The hgatp.VMID mask defines are used before shifting when extracting VMID value from hgatp CSR value so based on the convention followed in the other parts of asm/csr.h, the hgatp.VMID mask defines should not have a _MASK suffix. Signed-off-by: Anup Patel Reviewed-by: Andrew Jones --- arch/riscv/include/asm/csr.h | 8 ++++---- arch/riscv/kvm/mmu.c | 3 +-- arch/riscv/kvm/vmid.c | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index d608dac4b19f..36d580528f90 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -131,12 +131,12 @@ #define HGATP32_MODE_SHIFT 31 #define HGATP32_VMID_SHIFT 22 -#define HGATP32_VMID_MASK _AC(0x1FC00000, UL) +#define HGATP32_VMID _AC(0x1FC00000, UL) #define HGATP32_PPN _AC(0x003FFFFF, UL) #define HGATP64_MODE_SHIFT 60 #define HGATP64_VMID_SHIFT 44 -#define HGATP64_VMID_MASK _AC(0x03FFF00000000000, UL) +#define HGATP64_VMID _AC(0x03FFF00000000000, UL) #define HGATP64_PPN _AC(0x00000FFFFFFFFFFF, UL) #define HGATP_PAGE_SHIFT 12 @@ -144,12 +144,12 @@ #ifdef CONFIG_64BIT #define HGATP_PPN HGATP64_PPN #define HGATP_VMID_SHIFT HGATP64_VMID_SHIFT -#define HGATP_VMID_MASK HGATP64_VMID_MASK +#define HGATP_VMID HGATP64_VMID #define HGATP_MODE_SHIFT HGATP64_MODE_SHIFT #else #define HGATP_PPN HGATP32_PPN #define HGATP_VMID_SHIFT HGATP32_VMID_SHIFT -#define HGATP_VMID_MASK HGATP32_VMID_MASK +#define HGATP_VMID HGATP32_VMID #define HGATP_MODE_SHIFT HGATP32_MODE_SHIFT #endif diff --git a/arch/riscv/kvm/mmu.c b/arch/riscv/kvm/mmu.c index 34b57e0be2ef..034746638fa6 100644 --- a/arch/riscv/kvm/mmu.c +++ b/arch/riscv/kvm/mmu.c @@ -748,8 +748,7 @@ void kvm_riscv_gstage_update_hgatp(struct kvm_vcpu *vcpu) unsigned long hgatp = gstage_mode; struct kvm_arch *k = &vcpu->kvm->arch; - hgatp |= (READ_ONCE(k->vmid.vmid) << HGATP_VMID_SHIFT) & - HGATP_VMID_MASK; + hgatp |= (READ_ONCE(k->vmid.vmid) << HGATP_VMID_SHIFT) & HGATP_VMID; hgatp |= (k->pgd_phys >> PAGE_SHIFT) & HGATP_PPN; csr_write(CSR_HGATP, hgatp); diff --git a/arch/riscv/kvm/vmid.c b/arch/riscv/kvm/vmid.c index 6cd93995fb65..6f4d4979a759 100644 --- a/arch/riscv/kvm/vmid.c +++ b/arch/riscv/kvm/vmid.c @@ -26,9 +26,9 @@ void kvm_riscv_gstage_vmid_detect(void) /* Figure-out number of VMID bits in HW */ old = csr_read(CSR_HGATP); - csr_write(CSR_HGATP, old | HGATP_VMID_MASK); + csr_write(CSR_HGATP, old | HGATP_VMID); vmid_bits = csr_read(CSR_HGATP); - vmid_bits = (vmid_bits & HGATP_VMID_MASK) >> HGATP_VMID_SHIFT; + vmid_bits = (vmid_bits & HGATP_VMID) >> HGATP_VMID_SHIFT; vmid_bits = fls_long(vmid_bits); csr_write(CSR_HGATP, old);