Skip to content

Commit 2ec077c

Browse files
author
Ingo Molnar
committed
Merge branch 'upstream-acpi-fixes' into WIP.x86/pti.base
Signed-off-by: Ingo Molnar <[email protected]>
2 parents 650400b + 4f89fa2 commit 2ec077c

File tree

3 files changed

+33
-58
lines changed

3 files changed

+33
-58
lines changed

arch/arm64/include/asm/fixmap.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ enum fixed_addresses {
5151

5252
FIX_EARLYCON_MEM_BASE,
5353
FIX_TEXT_POKE0,
54+
55+
#ifdef CONFIG_ACPI_APEI_GHES
56+
/* Used for GHES mapping from assorted contexts */
57+
FIX_APEI_GHES_IRQ,
58+
FIX_APEI_GHES_NMI,
59+
#endif /* CONFIG_ACPI_APEI_GHES */
60+
5461
__end_of_permanent_fixed_addresses,
5562

5663
/*

arch/x86/include/asm/fixmap.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ enum fixed_addresses {
104104
FIX_GDT_REMAP_BEGIN,
105105
FIX_GDT_REMAP_END = FIX_GDT_REMAP_BEGIN + NR_CPUS - 1,
106106

107+
#ifdef CONFIG_ACPI_APEI_GHES
108+
/* Used for GHES mapping from assorted contexts */
109+
FIX_APEI_GHES_IRQ,
110+
FIX_APEI_GHES_NMI,
111+
#endif
112+
107113
__end_of_permanent_fixed_addresses,
108114

109115
/*

drivers/acpi/apei/ghes.c

Lines changed: 20 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <acpi/actbl1.h>
5252
#include <acpi/ghes.h>
5353
#include <acpi/apei.h>
54+
#include <asm/fixmap.h>
5455
#include <asm/tlbflush.h>
5556
#include <ras/ras_event.h>
5657

@@ -112,7 +113,7 @@ static DEFINE_MUTEX(ghes_list_mutex);
112113
* Because the memory area used to transfer hardware error information
113114
* from BIOS to Linux can be determined only in NMI, IRQ or timer
114115
* handler, but general ioremap can not be used in atomic context, so
115-
* a special version of atomic ioremap is implemented for that.
116+
* the fixmap is used instead.
116117
*/
117118

118119
/*
@@ -126,8 +127,8 @@ static DEFINE_MUTEX(ghes_list_mutex);
126127
/* virtual memory area for atomic ioremap */
127128
static struct vm_struct *ghes_ioremap_area;
128129
/*
129-
* These 2 spinlock is used to prevent atomic ioremap virtual memory
130-
* area from being mapped simultaneously.
130+
* These 2 spinlocks are used to prevent the fixmap entries from being used
131+
* simultaneously.
131132
*/
132133
static DEFINE_RAW_SPINLOCK(ghes_ioremap_lock_nmi);
133134
static DEFINE_SPINLOCK(ghes_ioremap_lock_irq);
@@ -159,52 +160,36 @@ static void ghes_ioremap_exit(void)
159160

160161
static void __iomem *ghes_ioremap_pfn_nmi(u64 pfn)
161162
{
162-
unsigned long vaddr;
163163
phys_addr_t paddr;
164164
pgprot_t prot;
165165

166-
vaddr = (unsigned long)GHES_IOREMAP_NMI_PAGE(ghes_ioremap_area->addr);
167-
168166
paddr = pfn << PAGE_SHIFT;
169167
prot = arch_apei_get_mem_attribute(paddr);
170-
ioremap_page_range(vaddr, vaddr + PAGE_SIZE, paddr, prot);
168+
__set_fixmap(FIX_APEI_GHES_NMI, paddr, prot);
171169

172-
return (void __iomem *)vaddr;
170+
return (void __iomem *) fix_to_virt(FIX_APEI_GHES_NMI);
173171
}
174172

175173
static void __iomem *ghes_ioremap_pfn_irq(u64 pfn)
176174
{
177-
unsigned long vaddr, paddr;
175+
phys_addr_t paddr;
178176
pgprot_t prot;
179177

180-
vaddr = (unsigned long)GHES_IOREMAP_IRQ_PAGE(ghes_ioremap_area->addr);
181-
182178
paddr = pfn << PAGE_SHIFT;
183179
prot = arch_apei_get_mem_attribute(paddr);
180+
__set_fixmap(FIX_APEI_GHES_IRQ, paddr, prot);
184181

185-
ioremap_page_range(vaddr, vaddr + PAGE_SIZE, paddr, prot);
186-
187-
return (void __iomem *)vaddr;
182+
return (void __iomem *) fix_to_virt(FIX_APEI_GHES_IRQ);
188183
}
189184

190-
static void ghes_iounmap_nmi(void __iomem *vaddr_ptr)
185+
static void ghes_iounmap_nmi(void)
191186
{
192-
unsigned long vaddr = (unsigned long __force)vaddr_ptr;
193-
void *base = ghes_ioremap_area->addr;
194-
195-
BUG_ON(vaddr != (unsigned long)GHES_IOREMAP_NMI_PAGE(base));
196-
unmap_kernel_range_noflush(vaddr, PAGE_SIZE);
197-
arch_apei_flush_tlb_one(vaddr);
187+
clear_fixmap(FIX_APEI_GHES_NMI);
198188
}
199189

200-
static void ghes_iounmap_irq(void __iomem *vaddr_ptr)
190+
static void ghes_iounmap_irq(void)
201191
{
202-
unsigned long vaddr = (unsigned long __force)vaddr_ptr;
203-
void *base = ghes_ioremap_area->addr;
204-
205-
BUG_ON(vaddr != (unsigned long)GHES_IOREMAP_IRQ_PAGE(base));
206-
unmap_kernel_range_noflush(vaddr, PAGE_SIZE);
207-
arch_apei_flush_tlb_one(vaddr);
192+
clear_fixmap(FIX_APEI_GHES_IRQ);
208193
}
209194

210195
static int ghes_estatus_pool_init(void)
@@ -360,10 +345,10 @@ static void ghes_copy_tofrom_phys(void *buffer, u64 paddr, u32 len,
360345
paddr += trunk;
361346
buffer += trunk;
362347
if (in_nmi) {
363-
ghes_iounmap_nmi(vaddr);
348+
ghes_iounmap_nmi();
364349
raw_spin_unlock(&ghes_ioremap_lock_nmi);
365350
} else {
366-
ghes_iounmap_irq(vaddr);
351+
ghes_iounmap_irq();
367352
spin_unlock_irqrestore(&ghes_ioremap_lock_irq, flags);
368353
}
369354
}
@@ -851,17 +836,8 @@ static void ghes_sea_remove(struct ghes *ghes)
851836
synchronize_rcu();
852837
}
853838
#else /* CONFIG_ACPI_APEI_SEA */
854-
static inline void ghes_sea_add(struct ghes *ghes)
855-
{
856-
pr_err(GHES_PFX "ID: %d, trying to add SEA notification which is not supported\n",
857-
ghes->generic->header.source_id);
858-
}
859-
860-
static inline void ghes_sea_remove(struct ghes *ghes)
861-
{
862-
pr_err(GHES_PFX "ID: %d, trying to remove SEA notification which is not supported\n",
863-
ghes->generic->header.source_id);
864-
}
839+
static inline void ghes_sea_add(struct ghes *ghes) { }
840+
static inline void ghes_sea_remove(struct ghes *ghes) { }
865841
#endif /* CONFIG_ACPI_APEI_SEA */
866842

867843
#ifdef CONFIG_HAVE_ACPI_APEI_NMI
@@ -1063,23 +1039,9 @@ static void ghes_nmi_init_cxt(void)
10631039
init_irq_work(&ghes_proc_irq_work, ghes_proc_in_irq);
10641040
}
10651041
#else /* CONFIG_HAVE_ACPI_APEI_NMI */
1066-
static inline void ghes_nmi_add(struct ghes *ghes)
1067-
{
1068-
pr_err(GHES_PFX "ID: %d, trying to add NMI notification which is not supported!\n",
1069-
ghes->generic->header.source_id);
1070-
BUG();
1071-
}
1072-
1073-
static inline void ghes_nmi_remove(struct ghes *ghes)
1074-
{
1075-
pr_err(GHES_PFX "ID: %d, trying to remove NMI notification which is not supported!\n",
1076-
ghes->generic->header.source_id);
1077-
BUG();
1078-
}
1079-
1080-
static inline void ghes_nmi_init_cxt(void)
1081-
{
1082-
}
1042+
static inline void ghes_nmi_add(struct ghes *ghes) { }
1043+
static inline void ghes_nmi_remove(struct ghes *ghes) { }
1044+
static inline void ghes_nmi_init_cxt(void) { }
10831045
#endif /* CONFIG_HAVE_ACPI_APEI_NMI */
10841046

10851047
static int ghes_probe(struct platform_device *ghes_dev)

0 commit comments

Comments
 (0)