From patchwork Mon Dec 9 05:32:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ganapatrao Kulkarni X-Patchwork-Id: 13898943 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 11F4EE77173 for ; Mon, 9 Dec 2024 05:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version: Content-Transfer-Encoding:Content-Type: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=gn2sBj7bIrZnFiYv4+EAHu5AMgw02NJanhY775oe6ZY=; b=XA1afrWEzDg2mdYPREPMRwJM1E OKse5/jHp+myR1RJaG9C5gfT4op0RrMWxR/zLFrOeWrUyEfb2EKNE9x3LzFx+xid56TEtfCIxs9Gs QSlUOMdaZBvK1yPXRIbQmc7qSB4uvqrpnpEPaaXxZ8bt7nS2+u6SyC3ZFu9IpKdMlL6RbWtys3x1f Zttb5wLIHg9W7RRG2r9sUsD0Z/uwRmxbakR2cP5gQ/rcA4CDnGoVJYmlaBzl91gxc0aLo020MhHb5 5FZBB4vYNL8HRZTfjSLefMBrM0KdBD+KMnR1XCJcURJ4YmjPIXy4uypItgeJbaZ4U0yF/9YZ8vxY1 dEkbiIJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKWQQ-00000006Vh9-2PEN; Mon, 09 Dec 2024 05:35:18 +0000 Received: from mail-dm6nam10on20713.outbound.protection.outlook.com ([2a01:111:f403:2413::713] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKWPO-00000006Vbw-0RFb for linux-arm-kernel@lists.infradead.org; Mon, 09 Dec 2024 05:34:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=I9ja6JUmZJHjIgl0QlT6YIohCYXCrVoy6m+/hacsgFEXknkHhSWLdOe9fI7OFR/0VwmkdI2irPykeTfl/W53ngnVo1q1x5ib5Vxc3YCKzn3XAwb+WVHaco1IYOi+xhczr1xNk9RLjjbBC8IfEwchoXEVFO7FKxvnn4Ld4S/8fQ/vwVn1jJKiZN3sjH+xKhSNeA4XFrDoH8imooBHBBxl73VlpbrF8xwJ9ykwRoOXsAnnwZLY5w0BKogLZ5OsDx4mro3H/6AlsIV+9Wi4v7aoofjU32x1iytgzxtYcVNLysFcfAdw2NvnhBdSHw5tY1/Hbni/inwOioCNLtJi/HH1BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=gn2sBj7bIrZnFiYv4+EAHu5AMgw02NJanhY775oe6ZY=; b=YhzQYibIumbmYIvYUlddfH5k/1Txuan9aCdj1g7Lyt/XBGFhHoz95Ed76Lfptt2rA0Pc+NGfIFLJJjc2NJeIRk83q5OV9N4tZabAWwX+z+VMYzrn3F1w7in66LdJvO9xUJCCWgnpExyvGFcrPRkO58ZouIqZwJYmckQGa0pXUb2JFPiCzq3fhQFX41TIaOqfmRus5B7RNgXSWXo5f1+ylvzVCZEaMEy7CrVp3rcWrctp68U/NQAzcEaKFEJIqJjtnfM6pUUlpjPZ4enwzzBPtUo4XJEm5vybMqzzw/AGJxXPXPnpz10A8cEeKmTtMZge5Re0ZDCVnt7a9lND81xGAQ== 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=gn2sBj7bIrZnFiYv4+EAHu5AMgw02NJanhY775oe6ZY=; b=gYxF/KaCIdAjpJtWBQWM6UVKE5Hl/Y61e2lBtGlUjbF/qvu+3w5GZ5B8LzccsqP+hkyi9RcwGUs1OgK1+ElaZ7Q5I4Z9aAqYwUFw46maCTtz9yULNAVEKqLSEOuO8/NKrcPdFay37Vr15Wes0itijbqsgy1iX8HrvXINetocygM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ2PR01MB8101.prod.exchangelabs.com (2603:10b6:a03:4f6::10) by CO1PR01MB6760.prod.exchangelabs.com (2603:10b6:303:f2::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.7; Mon, 9 Dec 2024 05:34:06 +0000 Received: from SJ2PR01MB8101.prod.exchangelabs.com ([fe80::292:6d9c:eb9a:95c9]) by SJ2PR01MB8101.prod.exchangelabs.com ([fe80::292:6d9c:eb9a:95c9%5]) with mapi id 15.20.8251.008; Mon, 9 Dec 2024 05:34:06 +0000 From: Ganapatrao Kulkarni To: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: maz@kernel.org, oliver.upton@linux.dev, christoffer.dall@arm.com, suzuki.poulose@arm.com, will@kernel.org, catalin.marinas@arm.com, coltonlewis@google.com, joey.gouly@arm.com, yuzenghui@huawei.com, darren@os.amperecomputing.com, gankulkarni@os.amperecomputing.com, vishnu@os.amperecomputing.com Subject: [PATCH] KVM: arm64: nv: Set ISTATUS for emulated timers, If timer expired Date: Sun, 8 Dec 2024 21:32:01 -0800 Message-ID: <20241209053201.339939-1-gankulkarni@os.amperecomputing.com> X-Mailer: git-send-email 2.47.0 X-ClientProxiedBy: CH5P223CA0001.NAMP223.PROD.OUTLOOK.COM (2603:10b6:610:1f3::27) To SJ2PR01MB8101.prod.exchangelabs.com (2603:10b6:a03:4f6::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ2PR01MB8101:EE_|CO1PR01MB6760:EE_ X-MS-Office365-Filtering-Correlation-Id: cca4a4d1-7f56-478e-8807-08dd1813193a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|7416014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?G44clqYN3nsNFVW4UFC/2ebS4xACWMr?= =?utf-8?q?67aHKRd97Uk5IFDkuoLBIGOgzmLga39AZR/ibdoFke3WkUnb8qXV2fTljfkKrueix?= =?utf-8?q?KDVgibPmy6Utyp7LdfUlI8eCTRN43nuc4ZozYL8v5UoNSvsuWXj4yrIq/mIkvlY4u?= =?utf-8?q?dIZeekXBCVt86xsUFc0kPmlL2CXGGyT2OaO0RjnqyRG5PDAG5Y0uIY12fza62wztZ?= =?utf-8?q?l6I513QiyU25jApiLaxZh4krjZoXmKG89rrM+Ym2qtJrbcaMasH4GX/RgKT3o1DHp?= =?utf-8?q?A0enuLLSVHbhtAu82iHV2UnFC7OMoFV+9jyVU/w/jC6HF1rSq3JeBSy5gj7+lnd3H?= =?utf-8?q?rAzcoppAGscC05swpPvK5B80zwjNNTFb2tn+A2iM43c5GRsmGRrnsb1bXarLQphse?=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6KaVdf7UpSeXGhVi5SeM8u7xdLLyQiOlfcH+aZTQ23iGU4GbBB3t7PtbI?= =?utf-8?q?KvDP3AkcAF3vj/3QpoRJ5jNY9Rb9iORrag=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ2PR01MB8101.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230040)(52116014)(376014)(7416014)(1800799024)(366016)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?nqvyruewTeeXpv81IvnFcRRDYKC2?= =?utf-8?q?W9squXHA9yXTR0kBNri9OZNkArrtkjdUXCI0B2+EL1+QEBsNMhjUGKHpng3teiBsz?= =?utf-8?q?oOtBeiRgDf3EcP9CTkoFBIdAOFTxlzB0kXa3YYKaJj6Tuhe1VhkGAcGxNZTkIeoCR?= =?utf-8?q?Z+Meas1y6+cLy21C8htu0yjj6ZXYmy8y2gUJrUojXth6JprtOaXwjcgCpocMNLXO0?= =?utf-8?q?GOlxjMLuhz0YNJ5n7KS8xiCPuw0XEKWkyiiWtckSr7U4IUVwHC4BX6vsVPEyUYdYj?= =?utf-8?q?owjUCG5I5AyqUW71eIhhnH/DF+waLQRZWROyxH4AB955quPEHPLjLRbhP/zMG0d/d?= =?utf-8?q?x8UwPFGmYafayTLUSmbJbY4z63xNNUW1lf9Zp9mJ1eM+/LNZmxE/Qe/HhxyXxF9hs?= =?utf-8?q?/WBPoFoAvWj9Nh6bB8ns+PHoJ2MuxiwcjwWAz1nJzPDhUrYKTlG9xiaioaUjvSFQA?= =?utf-8?q?6Ih/yKX0zq3NNROlxt1K29L+w23DpYzjFtLUNy+V5HTQB/9B+iDDrmqPHJbjE30LR?= =?utf-8?q?NS7yuSl2Jk7HeozC0wY1rkwAcv7J1PmpIW/7f9l7nfeFr97g92d8p2SCnfJbRTzGF?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q?QZ35emEIiRvNJ9JBFWDSeFU43XljRzofym7pk2vhW8uR3Rgx/hawfdKeetmPOg7PE?= =?utf-8?q?qMURUWaSDB6/hJy3Pe83uezaILBSqEg0lyuyT9kdexO2PcKfIbFmPb0=3D?= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: cca4a4d1-7f56-478e-8807-08dd1813193a X-MS-Exchange-CrossTenant-AuthSource: SJ2PR01MB8101.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2024 05:34:06.4869 (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: QYz+5LBYrax4wqabKUCIyZLSkt/AnSqw9QBjwl/PgsuHdgtm+dFm+cFhyhSlv4b16+pNVGOsAnxH2AbNuEXR1rMRiDipIJny8arOE8gXzlM6/H4VSaXUjCkj6jPktAlD X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR01MB6760 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241208_213414_158406_1C28F90E X-CRM114-Status: GOOD ( 13.79 ) 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 During automated testing of Nested Virtualization using avocado-vt, it has been observed that during some boot test iterations, the Guest-Hypervisor boot was getting crashed with a synchronous exception while it is still booting EDK2. The test is launching Multiple instances of Guest-Hypervisor boot and while booting, QEMU monitor issued the command "info register" at regular intervals to take a register dump. To execute this command, QEMU stops the run and does the register read of various registers. While resuming the run, the function kvm_arm_timer_write() writes back the saved CNTV_CTL_EL0 register with ISTATUS cleared always and resulting in the loss of pending interrupt for emulated timers. In hardware based timers, ISTATUS is a RO/WI bit and gets set by the h/w, if the condition is still met. However, in Nested-Virtualization case, the Guest-Hypervisor's EDK2 is using an emulated virtual timer and losing ISTATUS state and the interrupt forever. Adding fix in kvm_arm_timer_write to set ISTATUS for emulated timers, if the timer expired already. Fixes: 81dc9504a700 ("KVM: arm64: nv: timers: Support hyp timer emulation") Co-developed-by: Vishnu Pajjuri Signed-off-by: Vishnu Pajjuri Signed-off-by: Ganapatrao Kulkarni --- arch/arm64/kvm/arch_timer.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c index 1215df590418..aca58113d790 100644 --- a/arch/arm64/kvm/arch_timer.c +++ b/arch/arm64/kvm/arch_timer.c @@ -1199,7 +1199,16 @@ static void kvm_arm_timer_write(struct kvm_vcpu *vcpu, break; case TIMER_REG_CTL: - timer_set_ctl(timer, val & ~ARCH_TIMER_CTRL_IT_STAT); + struct timer_map map; + + val &= ~ARCH_TIMER_CTRL_IT_STAT; + get_timer_map(vcpu, &map); + /* Set ISTATUS bit for emulated timers, if timer expired. */ + if (timer == map.emul_vtimer || timer == map.emul_ptimer) { + if (!kvm_timer_compute_delta(timer)) + val |= ARCH_TIMER_CTRL_IT_STAT; + } + timer_set_ctl(timer, val); break; case TIMER_REG_CVAL: