Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp986286rdb; Fri, 20 Oct 2023 05:34:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH8NL69UpacyG0Cgy15n69KE04rH12b+VAbIxHZxTz2A3k2woHj3eYO161jMZf6bHH8Kl/m X-Received: by 2002:a17:903:42cb:b0:1c9:bfdc:7efe with SMTP id jy11-20020a17090342cb00b001c9bfdc7efemr1525773plb.68.1697805285734; Fri, 20 Oct 2023 05:34:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697805285; cv=none; d=google.com; s=arc-20160816; b=eKaz+xDq+c4PXPkvUEkVKTEGc2gdzA7dRdM4jcxGe1iDNXWKGOOrjYPUxkQ6QAtDgG BI049A6DFyLn7DxR37mSoh9JalSo8EHltyHpiUt8RyqXnDweIzkt16hY+DVrdmWQiafC jD3SfeslOMpRbahlCbQUEYIarOqHzhUD49E1c8giGfVvffNpnQX5tgmUSTRcpRgm7pIF MZsJLItRW8mtORemsS2nyVzhdYvTWN6/IaYFQW1F80qWEEeTDb+YZcO6wQyXcnk4/3bs zLJZDQ1FY3dCZqaZisiChAVrp/SWmOULNeWEtgHtBSMSY9LfzfHiP/n4yZbgY3hxq8H6 os8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=mLs6t96orijyqhiJaApN08RdPVruWuFLPAf201rGNHc=; fh=HXgKhMpP3NR0oFIvtr7coEU3Z/s2pWD4Y60/u8oLjgg=; b=jj89qH0oGX2Rxk0THmn2ATUQPGcdF/iT7ZXT2RsvBNNsM+dcASPyaGovcMJpQhN5Vd 0Sfx/J08xSrLk2kpWPabbiI9E7Tcu/XQBcOoJP4eUo8GHuzL6+9Z97cCa13L25HyKiLq 6f9u49BXJjUAyztzILQX8mP9fXbrS84l+21V7B0ZOZHlRAzG9GTztVsU/0Rv84XSRE0i 3arPNEDz58pEr7EJyoVXKw2qtdne+4uYqKhxwoAtJ+EF8TAEHGWJfY+WeoevzSjlNyPE 5Fz24usxE+SieEnrfiX2oAp3STkYwiY4GgmY/nq4lOniKfizVZFzfsHcErBQst/ry361 tlkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kSML7rlS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id p8-20020a1709026b8800b001c3845d008csi1590123plk.424.2023.10.20.05.34.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 05:34:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=kSML7rlS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 8A327835CEA1; Fri, 20 Oct 2023 05:34:42 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377288AbjJTMe3 (ORCPT + 99 others); Fri, 20 Oct 2023 08:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377079AbjJTMe2 (ORCPT ); Fri, 20 Oct 2023 08:34:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61DB193 for ; Fri, 20 Oct 2023 05:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1697805265; x=1729341265; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=KbNvs0px0D1QU2CACqrpgox2LilZmVWe6/Qr9SDWOLU=; b=kSML7rlSrK4lEcL+LDwonLwZ6CHHeAcmIvY46FLwgHUA0xh1SEBn73Gu O/mOoW110rWjeLkb7CkOQGuja9OZVj0hhHxJTodSSCoI/yFnP6Hxxbfow NWQUImN4xbd91bUBv88Zi8h94dtgGBLRv2rM5Yu8FT9XxcfJo0wypBoGn cKZdmV+DwDIbyzTPY7xeI/TK+ri90KXrIF7NA14ksl0CiiWDOZlr4YgMx mddnkKDNGKN/kpXOxpfeuhstPzV/1mIUXqkCJz3wi9x7wbCpWhKarl0Mh vFuD/fMJoxKVLpHzA1y7QxRBL/hLnUqtS5qNz+Ky2gasxlaQR/NME31Md w==; X-IronPort-AV: E=McAfee;i="6600,9927,10868"; a="371559980" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="371559980" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 05:34:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10869"; a="873891358" X-IronPort-AV: E=Sophos;i="6.03,238,1694761200"; d="scan'208";a="873891358" Received: from dgutows1-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.249.39.237]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Oct 2023 05:34:20 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 0249010A1C7; Fri, 20 Oct 2023 15:34:17 +0300 (+03) Date: Fri, 20 Oct 2023 15:34:17 +0300 From: "kirill.shutemov@linux.intel.com" To: "Huang, Kai" Cc: "tglx@linutronix.de" , "mingo@redhat.com" , "x86@kernel.org" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "Edgecombe, Rick P" , "Reshetova, Elena" , "Nakajima, Jun" , "rafael@kernel.org" , "peterz@infradead.org" , "sathyanarayanan.kuppuswamy@linux.intel.com" , "Hunter, Adrian" , "thomas.lendacky@amd.com" , "linux-kernel@vger.kernel.org" , "kexec@lists.infradead.org" , "linux-coco@lists.linux.dev" Subject: Re: [PATCH 13/13] x86/acpi: Add support for CPU offlining for ACPI MADT wakeup method Message-ID: <20231020123417.2577fm526juwggkf@box.shutemov.name> References: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> <20231005131402.14611-14-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 20 Oct 2023 05:34:43 -0700 (PDT) On Fri, Oct 20, 2023 at 11:21:34AM +0000, Huang, Kai wrote: > > > --- /dev/null > > +++ b/arch/x86/kernel/acpi/madt.S > > @@ -0,0 +1,28 @@ > > +#include > > +#include > > +#include > > +#include > > + > > + .text > > + .align PAGE_SIZE > > +SYM_FUNC_START(asm_acpi_mp_play_dead) > > + /* Load address of reset vector into RCX to jump when kernel is ready */ > > + movq acpi_mp_reset_vector_paddr(%rip), %rcx > > + > > + /* zero out flags, and disable interrupts */ > > + pushq $0 > > + popfq > > + > > + /* Turn off global entries. Following CR3 write will flush them. */ > > + movq %cr4, %rdx > > + andq $~(X86_CR4_PGE), %rdx > > + movq %rdx, %cr4 > > + > > + /* Switch to identity mapping */ > > + movq acpi_mp_pgd(%rip), %rax > > + movq %rax, %cr3 > > + > > + /* Jump to reset vector */ > > + ANNOTATE_RETPOLINE_SAFE > > + jmp *%rcx > > +SYM_FUNC_END(asm_acpi_mp_play_dead) > > diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt_wakeup.c > > index 4e92d1d4a5fa..2cc8590ec7a5 100644 > > --- a/arch/x86/kernel/acpi/madt_wakeup.c > > +++ b/arch/x86/kernel/acpi/madt_wakeup.c > > @@ -1,12 +1,162 @@ > > #include > > #include > > +#include > > +#include > > +#include > > +#include > > #include > > +#include > > > > /* Physical address of the Multiprocessor Wakeup Structure mailbox */ > > static u64 acpi_mp_wake_mailbox_paddr; > > /* Virtual address of the Multiprocessor Wakeup Structure mailbox */ > > static struct acpi_madt_multiproc_wakeup_mailbox *acpi_mp_wake_mailbox; > > > > +unsigned long acpi_mp_pgd; > > +u64 acpi_mp_reset_vector_paddr; > > Nit:? > > They are both physical address. It's a little bit odd for one to use 'unsigned > long' and the other to use 'u64'. Okay, I will make them both u64. > > + > > +void asm_acpi_mp_play_dead(void); > > + > > +static void __init *alloc_pgt_page(void *context) > > +{ > > + return memblock_alloc(PAGE_SIZE, PAGE_SIZE); > > +} > > If I am reading correclty, @context is never used. It's not used inside this > function, and all the callers call this with @context = NULL. Yes. We need the argument to conform to x86_mapping_info::alloc_pgt_page interface. > > + > > +static void acpi_mp_play_dead(void) > > +{ > > + idle_task_exit(); > > + cpuhp_ap_report_dead(); > > + asm_acpi_mp_play_dead(); > > +} > > + > > Looks you can use play_dead_common() here, if you take IRQ disable part out from > the assembly, because play_dead_common() does: > > void play_dead_common(void) > { > idle_task_exit(); > > cpuhp_ap_report_dead(); > > local_irq_disable(); > } Okay, fair enough. -- Kiryl Shutsemau / Kirill A. Shutemov