From patchwork Wed Nov 17 06:02:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 12623739 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DD9BC433F5 for ; Wed, 17 Nov 2021 06:03:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 28061613A3 for ; Wed, 17 Nov 2021 06:03:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 28061613A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=XzHKeZ/y2YgykYeOVj45U0Z7ooUVkdlPl0p6osLRG3E=; b=sEK1sXVRaOJZW2 KKjEzUY1BcfaXsV8I49+NSrqFsvnfqPVrnqV9bwazbF6Inl8NHxUANmUXOv39eswXf9rrN5R3v4Dx ahLPAXF2GfVNtoOBUfdN0aZHtyU5uE/KJbKY9v+3P330lYylcKODgvLhR4mw2DreIYkXkZjL7Vfk1 peWpwT/YY6IjWx/NImc2DNh20bSKYyjmB1XJbOxt6YhxkTJFSBaSEIRKbN4joM+wuV1mu5DIxzDks ZBOfmL24S3PHD33x6h0VkQBM5Zw8R4sq2kC76mzf+QkLMabTxfpDd2h5aEbQQXLN1JddMsskJQ/TE +4BL0R91lM/5ZCDffK4Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnE2O-003P2Z-Cb; Wed, 17 Nov 2021 06:03:16 +0000 Received: from esa6.hgst.iphmx.com ([216.71.154.45]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mnE2L-003P0W-7J; Wed, 17 Nov 2021 06:03:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1637128993; x=1668664993; h=from:to:cc:subject:date:message-id: content-transfer-encoding:mime-version; bh=DgrArfVV0tvxCuvr6+eRqMyiA24fpY951h3yxIURp5M=; b=A6VRLkW2X+VgRLKoVM3lxt+K/ygHJ/UBvxDKLUGTt0XPy+e7Bkd48Q3S H0Wv4kh1vB+sh77yPOykqZUOTH0nLG63DF6VVUYc+aRyc5rrQuEZvxxay UVnrBvA2sB6/rl0rdRqJ95uzIiumbi6lo+wTj48K0KPhHvXJ+CXA9ee2L KQgsB9+jMaqIrks0iBZ6u8fMRgKr4M/SpTleMmX4luHZ9V+Qgm3Xf/0d/ 6Uq1b3ZC3+KcrAXjurbTcm8LLdinF+R58FuxBPpQxiH4Z4gd2NxxQKyeh b8qof4aEIdXvXzm9vIEbQdinf5JABDNHGIUzS7JnVGfdBl18fDBYVarRl w==; X-IronPort-AV: E=Sophos;i="5.87,240,1631548800"; d="scan'208";a="186809932" Received: from mail-dm6nam08lp2040.outbound.protection.outlook.com (HELO NAM04-DM6-obe.outbound.protection.outlook.com) ([104.47.73.40]) by ob1.hgst.iphmx.com with ESMTP; 17 Nov 2021 14:03:08 +0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UlEJBEI2YveQlv8vOgCzEX4dyZwMaJTz1YDFoiLF7cXkCtISavj5Xn1LdfdO1r6Tc0LVaGuI5p9r6mLzpunslBYyzuXNN+jxVyom07KgmnZKJk3Qk8cf1JtjNUXsmK/fkvOF3ATtbQtAbd+eGb2rB0zBAihCDTD3qD56lSLL8mBKiEuAD/JotnuWb6WtWs9iN0u/NtILQBLfQ1cNBErlWIC6NecqsRs/639oFufXXTMtfTyTcq2eR+ujIHHQ0PnZ9dXRAG26HCISmqGCHowoJkyglXpbnscRoFZQFDS3t2aiygzpw8y/UxlgegdOJbnnp7+4feejwNIdp8HRIcfHtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/rW2jUfnoSx4YFbNS6ptfich34DRCgs9w+4V4ArfhJo=; b=avO3d+9BIC7OElifIm4hnzjhdcNNsrW7DlZ1J4DWOCjKW9k2IwnaRWC64zarqipVsdJ+T3rOvIzms0oygjV6gNCfYPWjhFh83dh6kD6Ff/rhf1TQxXwwKn7gxuxNDT4vUVl5qp/9Y8NZbN6x/f6vSC1PYBIPV+tPrXBOIxnEGwOJNoU2SsjL4PHeVXneaeq2Dj6aTDbF2zWlWG+4Sx3cl00ajQWhFgj7F6dxzTbnTv8pIrrTtSY+T2kpUDHT6VUwlQI/WXidTnEKVVGpyauk9G8vrwIGiLXmr4oXLBGtCo0JXPpvqpjG02FY2IjO4JZMI610rWq/GWpZ5h4MFycl6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wdc.com; dmarc=pass action=none header.from=wdc.com; dkim=pass header.d=wdc.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/rW2jUfnoSx4YFbNS6ptfich34DRCgs9w+4V4ArfhJo=; b=iqPYC1QjaAzu8lvhGQQlT80L5KYamabHLEabU7XyXH/fi3W+ogURGxKKOSZDA8B6wzACDzqvEO1IUXVZgbOr6+j8GvARmDz9XxXnyGPTrDIkI7TTC63S0bVDoaF51POnvtQHwgA39/F5/4MVIulB6C0Mn3pZI347G6k4Ox0K7vs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wdc.com; Received: from CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) by CO6PR04MB7891.namprd04.prod.outlook.com (2603:10b6:5:35b::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19; Wed, 17 Nov 2021 06:03:06 +0000 Received: from CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97]) by CO6PR04MB7812.namprd04.prod.outlook.com ([fe80::8100:4308:5b21:8d97%8]) with mapi id 15.20.4713.019; Wed, 17 Nov 2021 06:03:06 +0000 From: Anup Patel To: Atish Patra Cc: Palmer Dabbelt , Paul Walmsley , Paolo Bonzini , Anup Patel , kvm-riscv@lists.infradead.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel Subject: [PATCH] RISC-V: KVM: Fix incorrect KVM_MAX_VCPUS value Date: Wed, 17 Nov 2021 11:32:41 +0530 Message-Id: <20211117060241.611391-1-anup.patel@wdc.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: MA1PR01CA0082.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00::22) To CO6PR04MB7812.namprd04.prod.outlook.com (2603:10b6:303:138::6) MIME-Version: 1.0 Received: from wdc.com (122.179.27.5) by MA1PR01CA0082.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.19 via Frontend Transport; Wed, 17 Nov 2021 06:03:03 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5a8d49c0-1a41-4df5-7466-08d9a98fec32 X-MS-TrafficTypeDiagnostic: CO6PR04MB7891: X-Microsoft-Antispam-PRVS: WDCIPOUTBOUND: EOP-TRUE X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eupSd5HpZ6NpvO/+C5WYkm3SoIAY/gZa2uDHrbMQXVA2LYwf9L/eM/zBSYkH9S01s3yQlBpSQkD30ypcWC93DuVEcinIsWOc140PMpoV9rc4IuMUUvIlOVfO8hkZ1ZIlz+jb0YRKVM1zxaAmPNJ0bacSgtDTh90AVYaLphbAcRS37oJHtiFfeqQQL6+V/nnMrblmvm4+yhWEmfQ9h13dJwErGiEyFPEDjIQjIUqvfxdr0Zu+Xf8iXlnpCHqPfNkyk45UbeqGVw/8Y1zhGaq8H0PWZqv2wA22yBcHJAfzxSWOjgJRL1D0xo1xUkbZzVMbwfyMRMzhUcW1ZVCZaI7aIsa+k3v9I1qZS3dhnYIFG3qzH1xfk+irIRv2WwjvnHWhdY77ZHhD8IbMe/Ck7Ss/aO0wKWitGnIR8GEvHUympYyRaDDv2fONnl5/i4kPxlu4UXaIrLU6g2gHN7lneKyDtfNkjXanx9WlB4jYk65mMVYUxA4G34hGmj/dfRs3ezN/t5zyPVPShs9jKlQew5/RoqbIVVV1PSrJyrn8+8uNdCdu64W6d4WWKjoDiEH3CsX798FBsovAjlKAeuN4P7djFuue8LAE+PpTaTbmzfSH6yPmFcjUC9GBmBTibA0k2iHy0FSN+fd/w8YWvrmHN52uepfaFaJFGFgYgWVB7qD/ELmKDhR+Fl0Jqiddol6kKS9o3swd15we/ra0XkckM5XOLA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO6PR04MB7812.namprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(2906002)(54906003)(44832011)(8886007)(83380400001)(508600001)(36756003)(82960400001)(38350700002)(2616005)(956004)(6666004)(316002)(55016002)(38100700002)(5660300002)(1076003)(66946007)(7696005)(6916009)(4326008)(8676002)(52116002)(66556008)(66476007)(4744005)(86362001)(186003)(26005)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A+690d9xDkrzcYC8OQhpkkdy94wJ4lxD12NRNnUvtWftUKTLkCZ7q8crf+xiQF4998uFQ96Sgn7WsHXYoAM3Ok/JaYa4RkAJLIbY85MFp2P1S9C/2dZHuHgYZZPlLUbf67JhE2ODOBEyVG9saNeDwlEWwhhywDjRpG7iyNYOugh1g989afxwjd8v+SUot4YH2l0Xnl9yqnl+Pl8pQ8PdKqvTiZsSBxgaTgxg3zUZzwbnFSqrrEUY6JE4MB2+uCkOMBQjbIgqJJuWTFIJRiR2r9usCREXJA7fGJUtlpyQtLmo52myXNk01lKLXfUyrvBc0eWMJGdVB1RwI3vKeZMpjX6Q8ntUQUOhoonpYDdPfpGY7MtnLXOvbHhUUMeTUggK6aTXPSH8UV24F1YJu1WOnf5rpQhoQO8o1uO5g4JDC+/JjiItvajKwZnBdwosebh1K73YywXrMcExtYQDxtMsxME56QN6mayF9wMGUSgY2RRwZfphRm6M4uKFljOdnqwbqPrzGFzz2gpB6f68SzaubkP42gZf60sHwDH49MkeBxD59Ji1GkL9Hy6zD68ApLHRnTpXBH9M7QJ8/huMYTH13taYp8YpVkjXnNloC/IDThCLO5Or1SqzCPIl3885dcIG64iq+JKO69QiaiS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-CrossTenant-AuthSource: CO6PR04MB7812.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2021 06:03:06.5718 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: EFucTe3jeqEq3fb/nNXzqXpwCHVOvWu9c76lXT7e5k9jSDsXoHnb+7fAetdfQCAegMEv3wTKa/7y6TsTC6bcAw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR04MB7891 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211116_220313_374766_9BADC35C X-CRM114-Status: GOOD ( 13.12 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The KVM_MAX_VCPUS value is supposed to be aligned with number of VMID bits in the hgatp CSR but the current KVM_MAX_VCPUS value is aligned with number of ASID bits in the satp CSR. Fixes: 99cdc6c18c2d ("RISC-V: Add initial skeletal KVM support") Signed-off-by: Anup Patel Reviewed-by: Atish Patra --- arch/riscv/include/asm/kvm_host.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/arch/riscv/include/asm/kvm_host.h b/arch/riscv/include/asm/kvm_host.h index 25ba21f98504..2639b9ee48f9 100644 --- a/arch/riscv/include/asm/kvm_host.h +++ b/arch/riscv/include/asm/kvm_host.h @@ -12,14 +12,12 @@ #include #include #include +#include #include #include -#ifdef CONFIG_64BIT -#define KVM_MAX_VCPUS (1U << 16) -#else -#define KVM_MAX_VCPUS (1U << 9) -#endif +#define KVM_MAX_VCPUS \ + ((HGATP_VMID_MASK >> HGATP_VMID_SHIFT) + 1) #define KVM_HALT_POLL_NS_DEFAULT 500000