platform/x86: intel_pmc_core: Do not ioremap RAM
PATCH 1/1 platform/x86: intel_pmc_core: Do not ioremap RAM
On a Xen-based PVH virtual machine with more than 4 GiB of RAM, intel_pmc_core fails initialization with the following warning message from the kernel, indicating that the driver is attempting to ioremap RAM:
------------[ cut here ]------------
ioremap on RAM at 0x00000000fe000000 - 0x00000000fe001fff
WARNING: CPU: 1 PID: 434 at arch/x86/mm/ioremap.c:186 __ioremap_caller.constprop.0+0x2aa/0x2c0
Modules linked in: intel_pmc_core_pltdrv(+) xen_netfront(+) intel_pmc_core \
crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel \
intel_rapl_perf pcspkr binfmt_misc u2mfn(O) xenfs xen_gntdev \
xen_gntalloc xen_blkback xen_privcmd xen_evtchn ip_tables overlay \
xen_blkfront
CPU: 1 PID: 434 Comm: systemd-udevd Tainted: G O 5.3.0-rc3-next-20190809-1 #2
RIP: 0010:__ioremap_caller.constprop.0+0x2aa/0x2c0
Code: 05 0f c9 1b 01 49 09 c6 e9 8e fe ff ff 48 8d 54 24 28 48 c7 c7 68 87 0a 82 c6 05 c4 23 2b 01 01 48 8d 74 24 18 e8 d4 4a 06 00 <0f> 0b 45 31 ff e9 fe fe ff ff e8 e7 47 06 00 0f 1f 80 00 00 00 00
RSP: 0018:ffffc900002dfa20 EFLAGS: 00010282
RAX: 0000000000000000 RBX: ffffffffc0107000 RCX: 0000000000000006
RDX: 0000000000000007 RSI: 0000000000000092 RDI: ffff88813bb17540
RBP: 00000000fe000000 R08: 000000000000015f R09: 000000000000000a
R10: 000000000000000a R11: ffffc900002df8da R12: 0000000000002000
R13: 0000000000000000 R14: 0000000000000002 R15: ffffffff822da3a0
FS: 000072ecce666940(0000) GS:ffff88813bb00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000785be7346d20 CR3: 000000000d872001 CR4: 00000000003606e0
Call Trace:
? pmc_core_probe+0x87/0x2d0 [intel_pmc_core]
pmc_core_probe+0x87/0x2d0 [intel_pmc_core]
platform_drv_probe+0x35/0x80
really_probe+0x298/0x3c0
driver_probe_device+0x7a/0x100
? driver_allows_async_probing+0x50/0x50
bus_for_each_drv+0x8f/0xd0
__device_attach+0xf0/0x170
bus_probe_device+0x8e/0xa0
device_add+0x692/0x7e0
platform_device_add+0xe9/0x240
? 0xffffffffc00ec000
do_one_initcall+0x59/0x214
do_init_module+0x5c/0x230
load_module+0x258d/0x2840
? __do_sys_finit_module+0xbb/0x120
__do_sys_finit_module+0xbb/0x120
do_syscall_64+0x5f/0x1a0
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x72eccf662fad
Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ab 9e 0c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffd3710d018 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
RAX: ffffffffffffffda RBX: 000060ab8fda2530 RCX: 000072eccf662fad
RDX: 0000000000000000 RSI: 000072eccf2bd84d RDI: 0000000000000017
RBP: 0000000000020000 R08: 0000000000000000 R09: 0000000000000007
R10: 0000000000000017 R11: 0000000000000246 R12: 000072eccf2bd84d
R13: 0000000000000000 R14: 000060ab8fd9b5e0 R15: 0000000000000007
---[ end trace 5e5421608729d6f4 ]---This issue appears to manifest itself because of the following fallback mechanism in the driver:
if (lpit_read_residency_count_address(&slp_s0_addr)) pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT;
The validity of address PMC_BASE_ADDR_DEFAULT (i.e., 0xFE000000) is not verified by the driver, which is what this patch introduces. With this patch, if address PMC_BASE_ADDR_DEFAULT is in RAM, then the driver will not attempt to ioremap the aforementioned address.
--- drivers/platform/x86/intel_pmc_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/intel_pmc_core.c +6 -2
@@ -878,10 +878,14 @@ static int pmc_core_probe(struct platform_device *pdev)if (pmcdev->map == &spt_reg_map && !pci_dev_present (pmc_pci_ids)) pmcdev->map = &cnp_reg_map; -if (lpit_read_residency_count_address (&slp_s0_addr)) +if (lpit_read_residency_count_address (&slp_s0_addr)) { pmcdev->base_addr =PMC_BASE_ADDR_DEFAULT ; -else + +if (page_is_ram (PHYS_PFN (pmcdev->base_addr))) +return -ENODEV ; + }else { pmcdev->base_addr = slp_s0_addr - pmcdev->map->slp_s0_offset; + } pmcdev->regbase =ioremap (pmcdev->base_addr, pmcdev->map->regmap_length);
Signature · 1 line
2.21.0
PATCH 1/1 platform/x86: intel_pmc_core_pltdrv: Module removal warning fix
Prior to this commit, removing the intel_pmc_core_pltdrv module would cause the following warning:
------------[ cut here ]------------
Device 'intel_pmc_core.0' does not have a release() function, \
it is broken and must be fixed. See Documentation/kobject.txt.
WARNING: CPU: 0 PID: 2202 at drivers/base/core.c:1238 device_release+0x6f/0x80
Modules linked in: fuse intel_rapl_msr ip6table_filter ip6_tables ipt_REJECT \
nf_reject_ipv4 xt_conntrack iptable_filter xt_MASQUERADE iptable_nat nf_nat \
nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c intel_rapl_common \
intel_pmc_core_pltdrv(-) xen_netfront intel_pmc_core crct10dif_pclmul \
crc32_pclmul crc32c_intel ghash_clmulni_intel intel_rapl_perf pcspkr binfmt_misc \
u2mfn(O) xenfs xen_gntdev xen_gntalloc xen_blkback xen_privcmd xen_evtchn \
ip_tables overlay xen_blkfront
CPU: 0 PID: 2202 Comm: rmmod Tainted: G W O 5.3.0-rc3-next-20190809-1 #2
RIP: 0010:device_release+0x6f/0x80
Code: 48 8b 85 c0 02 00 00 48 85 c0 74 09 48 8b 40 40 48 85 c0 75 c6 48 8b 75 50 48 85 f6 74 10 48 c7 c7 58 68 12 82 e8 5f 62 a9 ff <0f> 0b eb b5 48 8b 75 00 eb ea 0f 1f 80 00 00 00 00 0f 1f 44 00 00
RSP: 0018:ffffc90000763ea8 EFLAGS: 00010286
RAX: 0000000000000000 RBX: ffffffff822da080 RCX: 0000000000000006
RDX: 0000000000000007 RSI: 0000000000000082 RDI: ffff88813ba17540
RBP: ffffffffc0107010 R08: 0000000000000195 R09: 000000000000000d
R10: 000000000000000a R11: ffffc90000763d65 R12: ffff88800c9e9000
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS: 000071250bf142c0(0000) GS:ffff88813ba00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000060ab8fd82d49 CR3: 00000001273ba004 CR4: 00000000003606f0
Call Trace:
kobject_put+0x85/0x1b0
__x64_sys_delete_module+0x14b/0x270
do_syscall_64+0x5f/0x1a0
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x71250c031c6b
Code: 73 01 c3 48 8b 0d 1d 42 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ed 41 0c 00 f7 d8 64 89 01 48
RSP: 002b:00007ffec29e6038 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
RAX: ffffffffffffffda RBX: 00006040bc3e07b0 RCX: 000071250c031c6b
RDX: 000000000000000a RSI: 0000000000000800 RDI: 00006040bc3e0818
RBP: 00007ffec29e6088 R08: 1999999999999999 R09: 0000000000000000
R10: 000071250c0a6ac0 R11: 0000000000000206 R12: 00007ffec29e6250
R13: 00007ffec29e67b7 R14: 00006040bc3e0260 R15: 00007ffec29e6090
---[ end trace 5e5421608729d6f5 ]---This commit hence adds an empty release function for the driver.
--- drivers/platform/x86/intel_pmc_core_pltdrv.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/platform/x86/intel_pmc_core_pltdrv.c +8 -0
@@ -18,8 +18,16 @@#include <asm/cpu_device_id.h> #include <asm/intel-family.h> +static void intel_pmc_core_release (struct device *dev) +{ +/* Nothing to do. */ +} +static struct platform_device pmc_core_device = { .name ="intel_pmc_core" , + .dev = { + .release = intel_pmc_core_release, + }, };/*
Signature · 1 line
2.21.0
Re: [PATCH] platform/x86: intel_pmc_core_pltdrv: Module removal warning fix
Quoted 42 lines · M. Vefa Bicakci
Prior to this commit, removing the
intel_pmc_core_pltdrvmodule would cause the following warning:------------[ cut here ]------------ Device 'intel_pmc_core.0' does not have a release() function, \ it is broken and must be fixed. See Documentation/kobject.txt. WARNING: CPU: 0 PID: 2202 at drivers/base/core.c:1238 device_release+0x6f/0x80 Modules linked in: fuse intel_rapl_msr ip6table_filter ip6_tables ipt_REJECT \ nf_reject_ipv4 xt_conntrack iptable_filter xt_MASQUERADE iptable_nat nf_nat \ nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 libcrc32c intel_rapl_common \ intel_pmc_core_pltdrv(-) xen_netfront intel_pmc_core crct10dif_pclmul \ crc32_pclmul crc32c_intel ghash_clmulni_intel intel_rapl_perf pcspkr binfmt_misc \ u2mfn(O) xenfs xen_gntdev xen_gntalloc xen_blkback xen_privcmd xen_evtchn \ ip_tables overlay xen_blkfront CPU: 0 PID: 2202 Comm: rmmod Tainted: G W O 5.3.0-rc3-next-20190809-1 #2 RIP: 0010:device_release+0x6f/0x80 Code: 48 8b 85 c0 02 00 00 48 85 c0 74 09 48 8b 40 40 48 85 c0 75 c6 48 8b 75 50 48 85 f6 74 10 48 c7 c7 58 68 12 82 e8 5f 62 a9 ff <0f> 0b eb b5 48 8b 75 00 eb ea 0f 1f 80 00 00 00 00 0f 1f 44 00 00 RSP: 0018:ffffc90000763ea8 EFLAGS: 00010286 RAX: 0000000000000000 RBX: ffffffff822da080 RCX: 0000000000000006 RDX: 0000000000000007 RSI: 0000000000000082 RDI: ffff88813ba17540 RBP: ffffffffc0107010 R08: 0000000000000195 R09: 000000000000000d R10: 000000000000000a R11: ffffc90000763d65 R12: ffff88800c9e9000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 FS: 000071250bf142c0(0000) GS:ffff88813ba00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 000060ab8fd82d49 CR3: 00000001273ba004 CR4: 00000000003606f0 Call Trace: kobject_put+0x85/0x1b0 __x64_sys_delete_module+0x14b/0x270 do_syscall_64+0x5f/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x71250c031c6b Code: 73 01 c3 48 8b 0d 1d 42 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ed 41 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffec29e6038 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0 RAX: ffffffffffffffda RBX: 00006040bc3e07b0 RCX: 000071250c031c6b RDX: 000000000000000a RSI: 0000000000000800 RDI: 00006040bc3e0818 RBP: 00007ffec29e6088 R08: 1999999999999999 R09: 0000000000000000 R10: 000071250c0a6ac0 R11: 0000000000000206 R12: 00007ffec29e6250 R13: 00007ffec29e67b7 R14: 00006040bc3e0260 R15: 00007ffec29e6090 ---[ end trace 5e5421608729d6f5 ]---
Quoted 2 lines
This commit hence adds an empty release function for the driver.
Pushed to my review and testing queue, thanks!
P.S. I cut unnecessary output off.
Quoted 29 lines
Signed-off-by M. Vefa Bicakci <[email protected]>--- drivers/platform/x86/intel_pmc_core_pltdrv.c | 8 ++++++++ 1 file changed, 8 insertions(+)drivers/platform/x86/intel_pmc_core_pltdrv.c +8
-1@@ -18,8 +18,16 @@#include <asm/cpu_device_id.h> #include <asm/intel-family.h> +static void intel_pmc_core_release (struct device *dev) +{ +/* Nothing to do. */ +} +static struct platform_device pmc_core_device = { .name ="intel_pmc_core" , + .dev = { + .release = intel_pmc_core_release, + }, };/* -- 2.21.0
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 12 lines · M. Vefa Bicakci
On a Xen-based PVH virtual machine with more than 4 GiB of RAM,
intel_pmc_corefails initialization with the following warning message from the kernel, indicating that the driver is attempting to ioremap RAM:------------[ cut here ]------------ ioremap on RAM at 0x00000000fe000000 - 0x00000000fe001fffThis issue appears to manifest itself because of the following fallback mechanism in the driver:
Quoted 7 lines
if (lpit_read_residency_count_address(&slp_s0_addr)) pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT;The validity of address
PMC_BASE_ADDR_DEFAULT(i.e.,0xFE000000) is not verified by the driver, which is what this patch introduces. With this patch, if addressPMC_BASE_ADDR_DEFAULTis in RAM, then the driver will not attempt to ioremap the aforementioned address.
Thank you for the patch.
Is there anything preventing us to use memremap() in such case?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 16 lines · On Fri, 16 Aug 2019 12:21:58 +0300 Andy Shevchenko <[email protected]>…
Quoted 15 lines · M. Vefa Bicakci
On a Xen-based PVH virtual machine with more than 4 GiB of RAM,
intel_pmc_corefails initialization with the following warning message from the kernel, indicating that the driver is attempting to ioremap RAM:------------[ cut here ]------------ ioremap on RAM at 0x00000000fe000000 - 0x00000000fe001fffThis issue appears to manifest itself because of the following fallback mechanism in the driver:
if (lpit_read_residency_count_address(&slp_s0_addr)) pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT;
Quoted 6 lines
Quoted 4 lines
The validity of address
PMC_BASE_ADDR_DEFAULT(i.e.,0xFE000000) is not verified by the driver, which is what this patch introduces. With this patch, if addressPMC_BASE_ADDR_DEFAULTis in RAM, then the driver will not attempt to ioremap the aforementioned address.Thank you for the patch.
Hello Andy,
Thank you for reviewing the patch!
Quoted 1 line
Is there anything preventing us to use
memremap()in such case?
I re-read the documentation for memremap a few times along with taking a look at its code, but I think I am missing an important piece of information. As I understand it, depending on its flags, memremap would allow a section of RAM to be mapped for the PMC driver.
The intention with this patch is to prevent the driver from being instantiated when the default/fallback memory address is in RAM, as this issue occurs with a non-administrative virtual machine (domU in Xen terminology) that does not simulate or pass-through a corresponding PMC device.
I think that I have misunderstood your review comment though, so I would apppreciate it if you could elaborate.
Thanks again for reviewing the patch,
Vefa
(Please note that my next reply may be delayed by about 10 hours.)
Quoted 59 lines · M. Vefa Bicakci
On a Xen-based PVH virtual machine with more than 4 GiB of RAM,
intel_pmc_corefails initialization with the following warning message from the kernel, indicating that the driver is attempting to ioremap RAM:------------[ cut here ]------------ ioremap on RAM at 0x00000000fe000000 - 0x00000000fe001fff WARNING: CPU: 1 PID: 434 at arch/x86/mm/ioremap.c:186 __ioremap_caller.constprop.0+0x2aa/0x2c0 Modules linked in: intel_pmc_core_pltdrv(+) xen_netfront(+) intel_pmc_core \ crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel \ intel_rapl_perf pcspkr binfmt_misc u2mfn(O) xenfs xen_gntdev \ xen_gntalloc xen_blkback xen_privcmd xen_evtchn ip_tables overlay \ xen_blkfront CPU: 1 PID: 434 Comm: systemd-udevd Tainted: G O 5.3.0-rc3-next-20190809-1 #2 RIP: 0010:__ioremap_caller.constprop.0+0x2aa/0x2c0 Code: 05 0f c9 1b 01 49 09 c6 e9 8e fe ff ff 48 8d 54 24 28 48 c7 c7 68 87 0a 82 c6 05 c4 23 2b 01 01 48 8d 74 24 18 e8 d4 4a 06 00 <0f> 0b 45 31 ff e9 fe fe ff ff e8 e7 47 06 00 0f 1f 80 00 00 00 00 RSP: 0018:ffffc900002dfa20 EFLAGS: 00010282 RAX: 0000000000000000 RBX: ffffffffc0107000 RCX: 0000000000000006 RDX: 0000000000000007 RSI: 0000000000000092 RDI: ffff88813bb17540 RBP: 00000000fe000000 R08: 000000000000015f R09: 000000000000000a R10: 000000000000000a R11: ffffc900002df8da R12: 0000000000002000 R13: 0000000000000000 R14: 0000000000000002 R15: ffffffff822da3a0 FS: 000072ecce666940(0000) GS:ffff88813bb00000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000785be7346d20 CR3: 000000000d872001 CR4: 00000000003606e0 Call Trace: ? pmc_core_probe+0x87/0x2d0 [intel_pmc_core] pmc_core_probe+0x87/0x2d0 [intel_pmc_core] platform_drv_probe+0x35/0x80 really_probe+0x298/0x3c0 driver_probe_device+0x7a/0x100 ? driver_allows_async_probing+0x50/0x50 bus_for_each_drv+0x8f/0xd0 __device_attach+0xf0/0x170 bus_probe_device+0x8e/0xa0 device_add+0x692/0x7e0 platform_device_add+0xe9/0x240 ? 0xffffffffc00ec000 do_one_initcall+0x59/0x214 do_init_module+0x5c/0x230 load_module+0x258d/0x2840 ? __do_sys_finit_module+0xbb/0x120 __do_sys_finit_module+0xbb/0x120 do_syscall_64+0x5f/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 RIP: 0033:0x72eccf662fad Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d ab 9e 0c 00 f7 d8 64 89 01 48 RSP: 002b:00007ffd3710d018 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 RAX: ffffffffffffffda RBX: 000060ab8fda2530 RCX: 000072eccf662fad RDX: 0000000000000000 RSI: 000072eccf2bd84d RDI: 0000000000000017 RBP: 0000000000020000 R08: 0000000000000000 R09: 0000000000000007 R10: 0000000000000017 R11: 0000000000000246 R12: 000072eccf2bd84d R13: 0000000000000000 R14: 000060ab8fd9b5e0 R15: 0000000000000007 ---[ end trace 5e5421608729d6f4 ]---This issue appears to manifest itself because of the following fallback mechanism in the driver:
Quoted 8 lines
if (lpit_read_residency_count_address(&slp_s0_addr)) pmcdev->base_addr = PMC_BASE_ADDR_DEFAULT;The validity of address
PMC_BASE_ADDR_DEFAULT(i.e.,0xFE000000) is not verified by the driver, which is what this patch introduces. With this patch, if addressPMC_BASE_ADDR_DEFAULTis in RAM, then the driver will not attempt to ioremap the aforementioned address.
Pushed to my review and testing queue, thanks!
P.S. I cut unnecessary output off.
Quoted 29 lines
Signed-off-by M. Vefa Bicakci <[email protected]>--- drivers/platform/x86/intel_pmc_core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/platform/x86/intel_pmc_core.c +6
-3@@ -878,10 +878,14 @@ static int pmc_core_probe(struct platform_device *pdev)if (pmcdev->map == &spt_reg_map && !pci_dev_present (pmc_pci_ids)) pmcdev->map = &cnp_reg_map; -if (lpit_read_residency_count_address (&slp_s0_addr)) +if (lpit_read_residency_count_address (&slp_s0_addr)) { pmcdev->base_addr =PMC_BASE_ADDR_DEFAULT ; -else + +if (page_is_ram (PHYS_PFN (pmcdev->base_addr))) +return -ENODEV ; + }else { pmcdev->base_addr = slp_s0_addr - pmcdev->map->slp_s0_offset; + } pmcdev->regbase =ioremap (pmcdev->base_addr, pmcdev->map->regmap_length); --2.21.0
Signature · 2 lines
With Best Regards, Andy Shevchenko