Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp1023343rwo; Wed, 2 Aug 2023 07:41:15 -0700 (PDT) X-Google-Smtp-Source: APBJJlEs1GOYgdgH1O7BQJMvrf9Rr4h/w6bFdWauyjTIEDiZvSFbh5bKcHNKFUuTYjDSIailkCwY X-Received: by 2002:a05:6402:1806:b0:522:b1aa:9f33 with SMTP id g6-20020a056402180600b00522b1aa9f33mr5225758edy.15.1690987275586; Wed, 02 Aug 2023 07:41:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690987275; cv=none; d=google.com; s=arc-20160816; b=J2Z/evsXJJ9OwxHeVHSATxukCt3De4yeo+a1lfsMPt1gHTa6mP61eUxvMthAAPSTS7 E7GRjcYCOFCXKzMu52f8xLL2e+6erSdaIqJZTAT27n6k+spUyH4r2QLojHNq7+1T/L0r aUobvDhWrZGI1LFf3ea7LcmFPbVeqXkpjY2EC3VkjswqRwkh+m0VRW6y6t1sWJ5H0/7T xZzmqR7HUBl0lPZQdGYcln6XnVgkIqd1l4dyl8vXYewnV7SGCZmTnkwgoOv2iQYxa78v w1ph5LgRT7MRY3gIoSwBFB3YXQLxaKcIcurhWSBKNkK28eKWNQEKZ7LeyyMztgFnN93h d8fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=eSqTqAulKMbSGEoqfLwtESawLk2CvunOU6UT9jjTXmM=; fh=kKKBnR/HUEa8FFaTOWbKL+aiZq4b2TUkRKylOH+G7rM=; b=F4KAahgfNRgWiOKgnAdFZFh7L96YpbPm1Bz+1DzOGMnq282gN9Y2y4vIUpxgUjgp2G PG5nck3NKm+ODGi3GQwlAboPaupITeamKdeLo/KbwefGXpMm+H0gTr3HulVmdOntwBoM 9kOJy2X8pPdE5FgZie4743t4Ax0UmEqGh+Y7PwvofxmfEr+rFDmuGfShb2yvAIGKCIag 4OJNSdtoYNA7qx00xUThii1xYBRHcx6bZIoQsDjGpJMPy4AX060vn1FiBshOq841ZzIp gA3rjUWOoJnC76HJNMS9ZJRZyXf2mc/cIAJ5Vt8YLhoIGhvYL/xhK3kX6M1VeS9nl78V J0cg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dy12-20020a05640231ec00b005226ec9b2c4si10121792edb.517.2023.08.02.07.40.48; Wed, 02 Aug 2023 07:41:15 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231897AbjHBOYe (ORCPT + 99 others); Wed, 2 Aug 2023 10:24:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbjHBOYc (ORCPT ); Wed, 2 Aug 2023 10:24:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8FAB126B6 for ; Wed, 2 Aug 2023 07:24:31 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 93E76113E; Wed, 2 Aug 2023 07:25:14 -0700 (PDT) Received: from [10.1.197.60] (eglon.cambridge.arm.com [10.1.197.60]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 708A63F5A1; Wed, 2 Aug 2023 07:24:30 -0700 (PDT) Message-ID: Date: Wed, 2 Aug 2023 15:24:18 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH v6] arm64: sdei: abort running SDEI handlers during crash Content-Language: en-GB To: D Scott Phillips , linux-arm-kernel@lists.infradead.org Cc: Catalin Marinas , Will Deacon , linux-kernel@vger.kernel.org, Darren Hart References: <20230627002939.2758-1-scott@os.amperecomputing.com> From: James Morse In-Reply-To: <20230627002939.2758-1-scott@os.amperecomputing.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Hi Scott, On 27/06/2023 01:29, D Scott Phillips wrote: > Interrupts are blocked in SDEI context, per the SDEI spec: "The client > interrupts cannot preempt the event handler." If we crashed in the SDEI > handler-running context (as with ACPI's AGDI) then we need to clean up the > SDEI state before proceeding to the crash kernel so that the crash kernel > can have working interrupts. > > Track the active SDEI handler per-cpu so that we can COMPLETE_AND_RESUME > the handler, discarding the interrupted context. I still argue this is a firmware bug. That preempt text was supposed to mean "PSTATE.DAIF get set", the whole "GIC abstraction" thing got shoehorned in much later. But I agree we need to work around it in linux. > diff --git a/drivers/firmware/arm_sdei.c b/drivers/firmware/arm_sdei.c > index f9040bd61081..285fe7ad490d 100644 > --- a/drivers/firmware/arm_sdei.c > +++ b/drivers/firmware/arm_sdei.c > @@ -1095,3 +1095,22 @@ int sdei_event_handler(struct pt_regs *regs, > return err; > } > NOKPROBE_SYMBOL(sdei_event_handler); > + > +void sdei_handler_abort(void) > +{ > + /* > + * If the crash happened in an SDEI event handler then we need to > + * finish the handler with the firmware so that we can have working > + * interrupts in the crash kernel. > + */ > + if (__this_cpu_read(sdei_active_critical_event)) { > + pr_warn("still in SDEI critical event context, attempting to finish handler.\n"); > + __sdei_handler_abort(); > + __this_cpu_write(sdei_active_critical_event, NULL); > + } > + if (__this_cpu_read(sdei_active_normal_event)) { > + pr_warn("still in SDEI normal event context, attempting to finish handler.\n"); > + __sdei_handler_abort(); > + __this_cpu_write(sdei_active_normal_event, NULL); > + } > +} I'm not sure why this moved out to drivers/firmware when the only caller is the arch code, but it doesn't matter... Reviewed-by: James Morse Thanks, James