From patchwork Wed Apr 20 20:44:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Elliot Berman X-Patchwork-Id: 12820789 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 F10F8C433EF for ; Wed, 20 Apr 2022 20:46:14 +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: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=qWNOEQ8ZHdK6jhq5aQNzcz7BfILu65j+iGEdo4DDH/0=; b=uxM9OFwhKHq4Id Nba4U+IXZFaJQObP697fGi2UEf0Q+XboErKjq8VRww0FVWJX/7VwRn6i6JcXW4pdwSX649yY3nKPE mcRG1hEWUj91rdwWYw6fzorrK8BWD5rYphvI0fE9PHLgAefhtZ+qX7nc+STMMv2qprs+8CtIGFEwv 0FYoBUcCPQLXW6XExX/Mu6+xqsb6wn7mztMpkfkCU4FzuyZdOkGrw++5Kegr2dXRmz2lJHrdl1uQ4 3/+tfIr9cWLtWGkE+p2w8ON0i3pMA99r7rNHJT5ABsBVySlCviTgyMhxN9QyXynvp/cWdacnAYDxs i3i2Rwrvaw6UAs/onYpA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhHCH-00ALPv-GF; Wed, 20 Apr 2022 20:45:09 +0000 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhHC7-00ALLo-HF for linux-arm-kernel@lists.infradead.org; Wed, 20 Apr 2022 20:45:01 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1650487499; x=1682023499; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=GpIdCWD/WGC20h2+9do7Cd7eJNXlQ2ceElVJQSTUdBI=; b=vors9ffkFCFxo9pmhlC22Za76GsqzEEtx5h5ULLPQkPwcCUMFMCuGwia X+pUlNfpeCd1y967+eAq1i8oYHux0NPgtURES7vOCoomqa6UpznM57X8z /+uJyjcDTxIQCr4/qsVEfD8dqaMQFB8wcVn5f2BPQObeY2BIkcifLqO7T k=; Received: from unknown (HELO ironmsg04-sd.qualcomm.com) ([10.53.140.144]) by alexa-out-sd-01.qualcomm.com with ESMTP; 20 Apr 2022 13:44:57 -0700 X-QCInternal: smtphost Received: from nasanex01b.na.qualcomm.com ([10.46.141.250]) by ironmsg04-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Apr 2022 13:44:57 -0700 Received: from hu-eberman-lv.qualcomm.com (10.49.16.6) by nasanex01b.na.qualcomm.com (10.46.141.250) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 20 Apr 2022 13:44:56 -0700 From: Elliot Berman To: Juergen Gross , "Srivatsa S. Bhat (VMware)" , Alexey Makhalov , "Catalin Marinas" , Will Deacon CC: Prakruthi Deepak Heragu , , , , , Murali Nalajala , Elliot Berman Subject: [PATCH] arm64: paravirt: Disable IRQs during stolen_time_cpu_down_prepare Date: Wed, 20 Apr 2022 13:44:17 -0700 Message-ID: <20220420204417.155194-1-quic_eberman@quicinc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01b.na.qualcomm.com (10.46.141.250) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_134459_718554_96957B71 X-CRM114-Status: GOOD ( 11.62 ) 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 From: Prakruthi Deepak Heragu During hotplug, the stolen time data structure is unmapped and memset. There is a possibility of the timer IRQ being triggered before memset and stolen time is getting updated as part of this timer IRQ handler. This causes the below crash in timer handler - [ 3457.473139][ C5] Unable to handle kernel paging request at virtual address ffffffc03df05148 ... [ 3458.154398][ C5] Call trace: [ 3458.157648][ C5] para_steal_clock+0x30/0x50 [ 3458.162319][ C5] irqtime_account_process_tick+0x30/0x194 [ 3458.168148][ C5] account_process_tick+0x3c/0x280 [ 3458.173274][ C5] update_process_times+0x5c/0xf4 [ 3458.178311][ C5] tick_sched_timer+0x180/0x384 [ 3458.183164][ C5] __run_hrtimer+0x160/0x57c [ 3458.187744][ C5] hrtimer_interrupt+0x258/0x684 [ 3458.192698][ C5] arch_timer_handler_virt+0x5c/0xa0 [ 3458.198002][ C5] handle_percpu_devid_irq+0xdc/0x414 [ 3458.203385][ C5] handle_domain_irq+0xa8/0x168 [ 3458.208241][ C5] gic_handle_irq.34493+0x54/0x244 [ 3458.213359][ C5] call_on_irq_stack+0x40/0x70 [ 3458.218125][ C5] do_interrupt_handler+0x60/0x9c [ 3458.223156][ C5] el1_interrupt+0x34/0x64 [ 3458.227560][ C5] el1h_64_irq_handler+0x1c/0x2c [ 3458.232503][ C5] el1h_64_irq+0x7c/0x80 [ 3458.236736][ C5] free_vmap_area_noflush+0x108/0x39c [ 3458.242126][ C5] remove_vm_area+0xbc/0x118 [ 3458.246714][ C5] vm_remove_mappings+0x48/0x2a4 [ 3458.251656][ C5] __vunmap+0x154/0x278 [ 3458.255796][ C5] stolen_time_cpu_down_prepare+0xc0/0xd8 [ 3458.261542][ C5] cpuhp_invoke_callback+0x248/0xc34 [ 3458.266842][ C5] cpuhp_thread_fun+0x1c4/0x248 [ 3458.271696][ C5] smpboot_thread_fn+0x1b0/0x400 [ 3458.276638][ C5] kthread+0x17c/0x1e0 [ 3458.280691][ C5] ret_from_fork+0x10/0x20 As a fix, disable the IRQs during hotplug until we unmap and memset the stolen time structure. Signed-off-by: Prakruthi Deepak Heragu Signed-off-by: Elliot Berman Reviewed-by: Juergen Gross --- arch/arm64/kernel/paravirt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm64/kernel/paravirt.c b/arch/arm64/kernel/paravirt.c index 75fed4460407..fc05a08557e0 100644 --- a/arch/arm64/kernel/paravirt.c +++ b/arch/arm64/kernel/paravirt.c @@ -70,13 +70,16 @@ static u64 para_steal_clock(int cpu) static int stolen_time_cpu_down_prepare(unsigned int cpu) { struct pv_time_stolen_time_region *reg; + unsigned long flags; reg = this_cpu_ptr(&stolen_time_region); if (!reg->kaddr) return 0; + local_irq_save(flags); memunmap(reg->kaddr); memset(reg, 0, sizeof(*reg)); + local_irq_restore(flags); return 0; }