From nobody Thu Dec 18 12:32:38 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BF3125523D; Wed, 19 Mar 2025 11:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742382246; cv=none; b=R3In/cQdSPKjwaglYxEJhJ8wqT/HObgbjONb/cE8eCpQbVEZwfUhh7MEtIJBqIarmR3OZXHFniAsxf+L3I5E18jqaGUuKIymkVbaQkDnlKJ3Jf4sVXDZELUKyjAzufdtZkHyuBmoc37JYhpP99jS5gGWx8w/hzSnS+/Dh0KY4BQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742382246; c=relaxed/simple; bh=DLu2RxqFmDZKQeOcYtCTykrCkdM9FsWxQrOBVoawnsI=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=tHXyr+stN0hEPFr0jeeztHXnN+TmiYI3z+bKAWAWylxgonBF1mIDBJN4+wDoPG/JA8OQ8f86Sd/dpx5O6Wd9Q5QYuDAD/SwDCpA/Q3oYo/iJnyLvMEtsGXV9zzOoRNG/h8wd4ADb9+EG79aID/td+3EqIDriFgnx4PAonibnjfM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=xA6N9OCj; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=UzufjOag; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="xA6N9OCj"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="UzufjOag" Date: Wed, 19 Mar 2025 11:04:01 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1742382242; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v2E2C/z78z6pzmoMTRd62BftgVGozSuSzbmmfv2iNbs=; b=xA6N9OCjU1HC6CmSx79oFj8srtIsezVfwME2TreofDLrRczyPlIuquoQq0Mx54ZODSy5MX T6mxKq5wxW2zOrKtqGXrO/AflkqNJ+6XNCZfC1ESH1UuaaUsYtvaav1MD5RC6HAwgJD/am q3V1BqUOmXZKU0XJp5+LyRxS5/ecgLN3WQj2e+qR1XYnnbMiZGSeIDm6Wa71e7e9vRLa3k rsrhrIZNbGUnhTz7GzcvQpxaswqz8KbKPBtHenOWT0rUgQUl/EL/69GcMY1sLq6nRPnc7y UV98CcxPNIx429oo/lKJpvf/6HvSE5l6Usg1LyoOMkcbvKB3qAHK7wN12VwSVg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1742382242; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=v2E2C/z78z6pzmoMTRd62BftgVGozSuSzbmmfv2iNbs=; b=UzufjOagSEAzVpZTJNCI+1U4UXhhJ4JdGtK5nA68JerheOo3CJXsErCs+cfXe3Vv8/4KsQ nGvtgmez8ovtQOCg== From: "tip-bot2 for Kirill A. Shutemov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/core] x86/acpi: Replace manual page table initialization with kernel_ident_mapping_init() Cc: "Kirill A. Shutemov" , Ingo Molnar , Kai Huang , Tom Lendacky , "Rafael J. Wysocki" , Andy Lutomirski , Linus Torvalds , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20241016111458.846228-3-kirill.shutemov@linux.intel.com> References: <20241016111458.846228-3-kirill.shutemov@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <174238224174.14745.17194430106877601796.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/core branch of tip: Commit-ID: 775d37d8f01ea1349be8bd7cc8651b51814c48df Gitweb: https://git.kernel.org/tip/775d37d8f01ea1349be8bd7cc8651b518= 14c48df Author: Kirill A. Shutemov AuthorDate: Wed, 16 Oct 2024 14:14:56 +03:00 Committer: Ingo Molnar CommitterDate: Wed, 19 Mar 2025 11:12:29 +01:00 x86/acpi: Replace manual page table initialization with kernel_ident_mappin= g_init() The init_transition_pgtable() functions maps the page with asm_acpi_mp_play_dead() into an identity mapping. Replace open-coded manual page table initialization with kernel_ident_mapping_init() to avoid code duplication. Use x86_mapping_info::offset to get the page mapped at the correct location. Signed-off-by: Kirill A. Shutemov Signed-off-by: Ingo Molnar Reviewed-by: Kai Huang Reviewed-by: Tom Lendacky Acked-by: Rafael J. Wysocki Cc: Andy Lutomirski Cc: Linus Torvalds Link: https://lore.kernel.org/r/20241016111458.846228-3-kirill.shutemov@lin= ux.intel.com --- arch/x86/kernel/acpi/madt_wakeup.c | 73 +++++------------------------ 1 file changed, 15 insertions(+), 58 deletions(-) diff --git a/arch/x86/kernel/acpi/madt_wakeup.c b/arch/x86/kernel/acpi/madt= _wakeup.c index d5ef621..f36f284 100644 --- a/arch/x86/kernel/acpi/madt_wakeup.c +++ b/arch/x86/kernel/acpi/madt_wakeup.c @@ -70,58 +70,6 @@ static void __init free_pgt_page(void *pgt, void *dummy) return memblock_free(pgt, PAGE_SIZE); } =20 -/* - * Make sure asm_acpi_mp_play_dead() is present in the identity mapping at - * the same place as in the kernel page tables. asm_acpi_mp_play_dead() sw= itches - * to the identity mapping and the function has be present at the same spo= t in - * the virtual address space before and after switching page tables. - */ -static int __init init_transition_pgtable(pgd_t *pgd) -{ - pgprot_t prot =3D PAGE_KERNEL_EXEC_NOENC; - unsigned long vaddr, paddr; - p4d_t *p4d; - pud_t *pud; - pmd_t *pmd; - pte_t *pte; - - vaddr =3D (unsigned long)asm_acpi_mp_play_dead; - pgd +=3D pgd_index(vaddr); - if (!pgd_present(*pgd)) { - p4d =3D (p4d_t *)alloc_pgt_page(NULL); - if (!p4d) - return -ENOMEM; - set_pgd(pgd, __pgd(__pa(p4d) | _KERNPG_TABLE)); - } - p4d =3D p4d_offset(pgd, vaddr); - if (!p4d_present(*p4d)) { - pud =3D (pud_t *)alloc_pgt_page(NULL); - if (!pud) - return -ENOMEM; - set_p4d(p4d, __p4d(__pa(pud) | _KERNPG_TABLE)); - } - pud =3D pud_offset(p4d, vaddr); - if (!pud_present(*pud)) { - pmd =3D (pmd_t *)alloc_pgt_page(NULL); - if (!pmd) - return -ENOMEM; - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE)); - } - pmd =3D pmd_offset(pud, vaddr); - if (!pmd_present(*pmd)) { - pte =3D (pte_t *)alloc_pgt_page(NULL); - if (!pte) - return -ENOMEM; - set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE)); - } - pte =3D pte_offset_kernel(pmd, vaddr); - - paddr =3D __pa(vaddr); - set_pte(pte, pfn_pte(paddr >> PAGE_SHIFT, prot)); - - return 0; -} - static int __init acpi_mp_setup_reset(u64 reset_vector) { struct x86_mapping_info info =3D { @@ -130,6 +78,7 @@ static int __init acpi_mp_setup_reset(u64 reset_vector) .page_flag =3D __PAGE_KERNEL_LARGE_EXEC, .kernpg_flag =3D _KERNPG_TABLE_NOENC, }; + unsigned long mstart, mend; pgd_t *pgd; =20 pgd =3D alloc_pgt_page(NULL); @@ -137,8 +86,6 @@ static int __init acpi_mp_setup_reset(u64 reset_vector) return -ENOMEM; =20 for (int i =3D 0; i < nr_pfn_mapped; i++) { - unsigned long mstart, mend; - mstart =3D pfn_mapped[i].start << PAGE_SHIFT; mend =3D pfn_mapped[i].end << PAGE_SHIFT; if (kernel_ident_mapping_init(&info, pgd, mstart, mend)) { @@ -147,14 +94,24 @@ static int __init acpi_mp_setup_reset(u64 reset_vector) } } =20 - if (kernel_ident_mapping_init(&info, pgd, - PAGE_ALIGN_DOWN(reset_vector), - PAGE_ALIGN(reset_vector + 1))) { + mstart =3D PAGE_ALIGN_DOWN(reset_vector); + mend =3D mstart + PAGE_SIZE; + if (kernel_ident_mapping_init(&info, pgd, mstart, mend)) { kernel_ident_mapping_free(&info, pgd); return -ENOMEM; } =20 - if (init_transition_pgtable(pgd)) { + /* + * Make sure asm_acpi_mp_play_dead() is present in the identity mapping + * at the same place as in the kernel page tables. + * asm_acpi_mp_play_dead() switches to the identity mapping and the + * function must be present at the same spot in the virtual address space + * before and after switching page tables. + */ + info.offset =3D __START_KERNEL_map - phys_base; + mstart =3D PAGE_ALIGN_DOWN(__pa(asm_acpi_mp_play_dead)); + mend =3D mstart + PAGE_SIZE; + if (kernel_ident_mapping_init(&info, pgd, mstart, mend)) { kernel_ident_mapping_free(&info, pgd); return -ENOMEM; }