From patchwork Wed Aug 24 06:03:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ganapatrao Kulkarni X-Patchwork-Id: 12952952 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 156BCC00140 for ; Wed, 24 Aug 2022 06:04:53 +0000 (UTC) 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:References:In-Reply-To: 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: List-Owner; bh=u7FrQEq+hEx/dLg5DYXVSHL1y7v2aRNVlRkZFY9mY1U=; b=mFhm6FlR+vAanD aX2uET0scLfovoX4kyO8U9EMKHQYakB6s5sbrj/7EGJEAx8awQ+nUYQYbwsgwxKHqEdDieIXi92jA gyZluI7lfi2PbTRyyVR9cLshnB71WrOIDlbQM8KR/whF772HFLL0oOqF1URQ4CRMFYwCwjzCaXh8t ka4u732bti0iyysppNU0KbT71SfhOw93gVHIEB6YM83YygZozu4U5wkIhrQJFF1ArQQ/ReqO4bKRY hNWU8t6WJsxebQUy9TDAb3KwjeAYpP94ilPQhfE8zMRhgfqAwEEmMQURvwV1TqQH/BNqDYjpRp6q7 xv/NjBBWRvmCsdggAHzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQjUQ-00Amfo-7o; Wed, 24 Aug 2022 06:03:46 +0000 Received: from mail-bn7nam10on2125.outbound.protection.outlook.com ([40.107.92.125] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oQjU7-00AmXo-Mz for linux-arm-kernel@lists.infradead.org; Wed, 24 Aug 2022 06:03:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NE+txOlWRiAJJVAuhs14BLwzD8afWx5IY6dgXnBo2qGoFOZoXguHvgPHIqlANj4kuqRJcg1xl2N9sC8R9wuzqpjbdj7NF6rvll9MVosP0M1S2Xh8TpNKZbLcIZ/5uNLlFwmmiIbTAy3kTNQCDpfJzA+vomfpe5HOd2+X0oe4NHCyMAeQLBdIhe7maOldpzS6Pq+Y5iIdYsRrq41RQCKbpiXi52T2mnb+aq4jHqz/YMcwi3OxivJudwZ5wAVepvQh95KeR4yNXq7LLDSEZzq6FkYLK7WMFLPIEUAU32ZP3AtWMdVGwVIRwjruoY9WVGq+vDWLyGBDRpdps5BtvZ+eCg== 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=4GI+nLH2hYI1BE5BBfDK5c8OIdM2maIvQks9FeJHJNs=; b=PBSGC6Lkg3mE3Rxs4THHKOYtADLRIxSEzej+Ja/rmU0MHHKcLuJwijHBU782j0bLOFpCOapqxr2+4YqW2jgb4Lgbpyd8REoqXgO3Q2dg+ck0jdiGjTBvBBxgU9R6ddnmG9JAGKPXWD/RPE9TuzSEDn4Uh5gYW2puYDsX4/rQIj20qv+qSlFk9v8I5j+R1F4HpchMOH6qdgHwHqE2PEVB+PXD7gAX4U/irPMzIfOdanMy6terEbc++HI7O6S7U23orPetYZnM9Ce4WZzeqAqD+1NYIEeUIGfZ2YS/fXfXXK2erMFlzwGtSzFOx2O0cTAizGHvMLxUF/FGxTlpDXdj8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4GI+nLH2hYI1BE5BBfDK5c8OIdM2maIvQks9FeJHJNs=; b=uEIh4yDOHFaMFA1HN/ZfbPUTpx3lhWJh1YdLdwLGYXujXDEYYdYUeZXu7GiBf4yduU0ukl/TugaAPTs94zsSHRkfwWIvZwfFnepeuyyUrzH66T3eVTgLZ3lB4WuVCyn9eJw3rvLAcRjLvVRBxmq23tjgJVEsGJaeWMi+4XeAju0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from DM8PR01MB6824.prod.exchangelabs.com (2603:10b6:8:23::24) by DM6PR01MB5914.prod.exchangelabs.com (2603:10b6:5:14f::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.21; Wed, 24 Aug 2022 06:03:20 +0000 Received: from DM8PR01MB6824.prod.exchangelabs.com ([fe80::7058:9dd4:aa01:614a]) by DM8PR01MB6824.prod.exchangelabs.com ([fe80::7058:9dd4:aa01:614a%4]) with mapi id 15.20.5546.022; Wed, 24 Aug 2022 06:03:20 +0000 From: Ganapatrao Kulkarni To: maz@kernel.org Cc: catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, scott@os.amperecomputing.com, gankulkarni@os.amperecomputing.com, keyur@os.amperecomputing.com Subject: [PATCH 2/3] KVM: arm64: nv: Emulate ISTATUS when emulated timers are fired. Date: Tue, 23 Aug 2022 23:03:03 -0700 Message-Id: <20220824060304.21128-3-gankulkarni@os.amperecomputing.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20220824060304.21128-1-gankulkarni@os.amperecomputing.com> References: <20220824060304.21128-1-gankulkarni@os.amperecomputing.com> X-ClientProxiedBy: CH0P220CA0030.NAMP220.PROD.OUTLOOK.COM (2603:10b6:610:ef::28) To DM8PR01MB6824.prod.exchangelabs.com (2603:10b6:8:23::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73cc6139-db46-4d8f-a1e4-08da8596586b X-MS-TrafficTypeDiagnostic: DM6PR01MB5914:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A3dm44bmCamI+RtBiPrPO9fmKmSuMqoeaJ6zYXRoRFS/HPfXKQV0RYe91lPwLpEWkrjf6jFK/5Vsfpdj6ffeeMe5DeA85X9v11stdwiJ1IwqJKwkkHshXUMG8oddau36L/PwG9F+ZKwNdQ/ijPj8ctTUpkFNTvGzSYCjQegLnyWZTdLVQOM38gJXcK90+PPjrjrs5B7oKumgh1W9nxrVi/Bwa3Lmc+qzHeV3mThHhJ3gjJMjYYP39VV8YYi2A5JEQlsUVSg2I9rlCbeoH0OuSyWPJO6Ong2vxQd/f99uIkuWRtsKMPN8NlOrhyNlxl51v9jRUfna2EqYyCZjHYa+R3OMKPq5N0ZD5xwL8veU5Eu0WFg/aZwa0CiAClnPW3zFyG8yHnDu5ukklMalBmvG/UYHYbfE8MFsnTVPIntj3XJAm9r2NKiG8W+u5vQEX3mUDwlm2rToFliPNZGq6xEq6nMH0olIvo9SQg0drvYjbdj2L2BoKEAvy2V94bT6z+xOtYLSwLw1cXyaw2zdA+cTfl65cU3hi/NI+Jmi6rJEoZRgR4p0FOmIMC/cWiPh1+M2xEIt+VroMy+2z+r87RO5uu5kTlIOoPEK8KyJsOwFKPIM66o4wN29+msgq0ic+MXEb85Hvzg5gL1O0kFiRWcdFS5/sKnwGzvdvmi/4BLwfVXwWXbodKADCC/N0JTNpQ8flmt1oGewEMi44gmjeR7Qqe0PQlbcMhYpRZ97XebBQ6EIreaSBEH/9EJYvLp80+dAh7kXbPsgN74aKrUIGlgZcw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM8PR01MB6824.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230016)(4636009)(366004)(39850400004)(396003)(376002)(136003)(346002)(86362001)(38100700002)(38350700002)(6916009)(316002)(2906002)(8676002)(4326008)(66946007)(66556008)(8936002)(66476007)(5660300002)(2616005)(1076003)(41300700001)(478600001)(6512007)(186003)(26005)(107886003)(6666004)(52116002)(6506007)(6486002)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6/rRiYdTavkf6rMwDC3ZJM5VEqdQx5whyokx+Blv/v333ue1f742GXgF9N/yLRKBxuHMxBT1IJmDWH2isJezzuD5lc3hrIuYrleyHZhPIKHU5RkoydL+s7eRZvbNVjw7w+P0x3cbdaWu0ELnNr4/DxMVClMIQR182Tu/PeuswLTC2ehb1TNJ1uEjmsqQ6m4K1neKwLdCWht6vNhatK/9GRcuCsUBBz3R9sCmgrLpZ+NecxK7GugOsG9XX3u77qewbE/016NeSS6Mv3zk95dsIDUuemXrlrmwO+yrgoTFCBJtWdfSI/Z2jbJVtmtUPYcYGpd27i3RmeJlVlYQKRkZCfGliB75Vduz3NDlGlZEBEEXmzzgcHEVL6ucMQ/nsF0xVrK0PRWD+4/Dz1d4ZmwUciyiNaGGXxLyndxza400qVh1dHq8ZG+uuU0O/SvkTMc+rd7Q8MiCU5izg8UsfJ+0ITwF3xqf+i1+DYNte2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il0K9v/Er4RpU5qBOvXCfH5bYiH+QZXeht57qpcEzTDkgO4FXQCNmM3X/v33U4y5w6ZwUGPz7wMqhZK+aUc= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73cc6139-db46-4d8f-a1e4-08da8596586b X-MS-Exchange-CrossTenant-AuthSource: DM8PR01MB6824.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2022 06:03:20.2477 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8ZQVqfrz5C4Jrj6uvRV+wx7jzNbTYD+49kCahV3yG19jebTsUR4pGMieuw1WZ3Cr4X6ozYlOOhAGJFGPgsvXI2u349tkccXgK3JHdYicWmM0X+ZH+2WYLE/N0dnIxe9H X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB5914 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220823_230327_818103_7974EBBE X-CRM114-Status: GOOD ( 10.95 ) X-BeenThere: linux-arm-kernel@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-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Guest-Hypervisor forwards the timer interrupt to Guest-Guest, if it is enabled, unmasked and ISTATUS bit of register CNTV_CTL_EL0 is set for a loaded timer. For NV2 implementation, the Host-Hypervisor is not emulating the ISTATUS bit while forwarding the Emulated Vtimer Interrupt to Guest-Hypervisor. This results in the drop of interrupt from Guest-Hypervisor, where as Host Hypervisor marked it as an active interrupt and expecting Guest-Guest to consume and acknowledge. Due to this, some of the Guest-Guest vCPUs are stuck in Idle thread and rcu soft lockups are seen. This issue is not seen with NV1 case since the register CNTV_CTL_EL0 read trap handler is emulating the ISTATUS bit. Adding code to set/emulate the ISTATUS when the emulated timers are fired. Signed-off-by: Ganapatrao Kulkarni --- arch/arm64/kvm/arch_timer.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 27a6ec46803a..0b32d943d2d5 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -63,6 +63,7 @@ static u64 kvm_arm_timer_read(struct kvm_vcpu *vcpu, struct arch_timer_context *timer, enum kvm_arch_timer_regs treg); static bool kvm_arch_timer_get_input_level(int vintid); +static u64 read_timer_ctl(struct arch_timer_context *timer); static struct irq_ops arch_timer_irq_ops = { .get_input_level = kvm_arch_timer_get_input_level, @@ -356,6 +357,8 @@ static enum hrtimer_restart kvm_hrtimer_expire(struct hrtimer *hrt) return HRTIMER_RESTART; } + /* Timer emulated, emulate ISTATUS also */ + timer_set_ctl(ctx, read_timer_ctl(ctx)); kvm_timer_update_irq(vcpu, true, ctx); return HRTIMER_NORESTART; } @@ -458,6 +461,8 @@ static void timer_emulate(struct arch_timer_context *ctx) trace_kvm_timer_emulate(ctx, should_fire); if (should_fire != ctx->irq.level) { + /* Timer emulated, emulate ISTATUS also */ + timer_set_ctl(ctx, read_timer_ctl(ctx)); kvm_timer_update_irq(ctx->vcpu, should_fire, ctx); return; }