* [v6,11/13] x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses
@ 2018-07-24 7:36 Ingo Molnar
0 siblings, 0 replies; 3+ messages in thread
From: Ingo Molnar @ 2018-07-24 7:36 UTC (permalink / raw)
To: Dan Williams
Cc: linux-nvdimm, Thomas Gleixner, Ingo Molnar, H. Peter Anvin,
Tony Luck, Borislav Petkov, linux-edac, x86, hch, linux-fsdevel,
linux-mm, linux-kernel
* Dan Williams <dan.j.williams@intel.com> wrote:
> In preparation for using set_memory_uc() instead set_memory_np() for
> isolating poison from speculation, teach the memtype code to sanitize
> physical addresses vs __PHYSICAL_MASK.
>
> The motivation for using set_memory_uc() for this case is to allow
> ongoing access to persistent memory pages via the pmem-driver +
> memcpy_mcsafe() until the poison is repaired.
>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Cc: Tony Luck <tony.luck@intel.com>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: <linux-edac@vger.kernel.org>
> Cc: <x86@kernel.org>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> arch/x86/mm/pat.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
> index 1555bd7d3449..6788ffa990f8 100644
> --- a/arch/x86/mm/pat.c
> +++ b/arch/x86/mm/pat.c
> @@ -512,6 +512,17 @@ static int free_ram_pages_type(u64 start, u64 end)
> return 0;
> }
>
> +static u64 sanitize_phys(u64 address)
> +{
> + /*
> + * When changing the memtype for pages containing poison allow
> + * for a "decoy" virtual address (bit 63 clear) passed to
> + * set_memory_X(). __pa() on a "decoy" address results in a
> + * physical address with it 63 set.
> + */
> + return address & __PHYSICAL_MASK;
s/it/bit
Thanks,
Ingo
---
To unsubscribe from this list: send the line "unsubscribe linux-edac" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [v6,11/13] x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses
@ 2018-07-24 15:46 Dave Jiang
0 siblings, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2018-07-24 15:46 UTC (permalink / raw)
To: Ingo Molnar, Dan Williams
Cc: Tony Luck, linux-nvdimm, x86, linux-kernel, linux-mm,
Ingo Molnar, Borislav Petkov, H. Peter Anvin, linux-fsdevel,
Thomas Gleixner, hch, linux-edac
On 07/24/2018 12:36 AM, Ingo Molnar wrote:
>
> * Dan Williams <dan.j.williams@intel.com> wrote:
>
>> In preparation for using set_memory_uc() instead set_memory_np() for
>> isolating poison from speculation, teach the memtype code to sanitize
>> physical addresses vs __PHYSICAL_MASK.
>>
>> The motivation for using set_memory_uc() for this case is to allow
>> ongoing access to persistent memory pages via the pmem-driver +
>> memcpy_mcsafe() until the poison is repaired.
>>
>> Cc: Thomas Gleixner <tglx@linutronix.de>
>> Cc: Ingo Molnar <mingo@redhat.com>
>> Cc: "H. Peter Anvin" <hpa@zytor.com>
>> Cc: Tony Luck <tony.luck@intel.com>
>> Cc: Borislav Petkov <bp@alien8.de>
>> Cc: <linux-edac@vger.kernel.org>
>> Cc: <x86@kernel.org>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> ---
>> arch/x86/mm/pat.c | 16 ++++++++++++++++
>> 1 file changed, 16 insertions(+)
>>
>> diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
>> index 1555bd7d3449..6788ffa990f8 100644
>> --- a/arch/x86/mm/pat.c
>> +++ b/arch/x86/mm/pat.c
>> @@ -512,6 +512,17 @@ static int free_ram_pages_type(u64 start, u64 end)
>> return 0;
>> }
>>
>> +static u64 sanitize_phys(u64 address)
>> +{
>> + /*
>> + * When changing the memtype for pages containing poison allow
>> + * for a "decoy" virtual address (bit 63 clear) passed to
>> + * set_memory_X(). __pa() on a "decoy" address results in a
>> + * physical address with it 63 set.
>> + */
>> + return address & __PHYSICAL_MASK;
>
> s/it/bit
Thanks Ingo! I'll update when I pull in the patch.
>
> Thanks,
>
> Ingo
> _______________________________________________
> Linux-nvdimm mailing list
> Linux-nvdimm@lists.01.org
> https://lists.01.org/mailman/listinfo/linux-nvdimm
>
---
To unsubscribe from this list: send the line "unsubscribe linux-edac" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* [v6,11/13] x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses
@ 2018-07-14 4:50 Dan Williams
0 siblings, 0 replies; 3+ messages in thread
From: Dan Williams @ 2018-07-14 4:50 UTC (permalink / raw)
To: linux-nvdimm
Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Tony Luck,
Borislav Petkov, linux-edac, x86, hch, linux-fsdevel, linux-mm,
linux-kernel
In preparation for using set_memory_uc() instead set_memory_np() for
isolating poison from speculation, teach the memtype code to sanitize
physical addresses vs __PHYSICAL_MASK.
The motivation for using set_memory_uc() for this case is to allow
ongoing access to persistent memory pages via the pmem-driver +
memcpy_mcsafe() until the poison is repaired.
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: <linux-edac@vger.kernel.org>
Cc: <x86@kernel.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
arch/x86/mm/pat.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
--
To unsubscribe from this list: send the line "unsubscribe linux-edac" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
index 1555bd7d3449..6788ffa990f8 100644
--- a/arch/x86/mm/pat.c
+++ b/arch/x86/mm/pat.c
@@ -512,6 +512,17 @@ static int free_ram_pages_type(u64 start, u64 end)
return 0;
}
+static u64 sanitize_phys(u64 address)
+{
+ /*
+ * When changing the memtype for pages containing poison allow
+ * for a "decoy" virtual address (bit 63 clear) passed to
+ * set_memory_X(). __pa() on a "decoy" address results in a
+ * physical address with it 63 set.
+ */
+ return address & __PHYSICAL_MASK;
+}
+
/*
* req_type typically has one of the:
* - _PAGE_CACHE_MODE_WB
@@ -533,6 +544,8 @@ int reserve_memtype(u64 start, u64 end, enum page_cache_mode req_type,
int is_range_ram;
int err = 0;
+ start = sanitize_phys(start);
+ end = sanitize_phys(end);
BUG_ON(start >= end); /* end is exclusive */
if (!pat_enabled()) {
@@ -609,6 +622,9 @@ int free_memtype(u64 start, u64 end)
if (!pat_enabled())
return 0;
+ start = sanitize_phys(start);
+ end = sanitize_phys(end);
+
/* Low ISA region is always mapped WB. No need to track */
if (x86_platform.is_untracked_pat_range(start, end))
return 0;
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-24 15:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-24 7:36 [v6,11/13] x86/mm/pat: Prepare {reserve, free}_memtype() for "decoy" addresses Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2018-07-24 15:46 Dave Jiang
2018-07-14 4:50 Dan Williams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).