Re: [tip:x86/boot] x86/mm: Enable KASLR for physical mapping memory regions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Subject: Re: [tip:x86/boot] x86/mm: Enable KASLR for physical mapping memory regions
- From: Kees Cook <keescook@xxxxxxxxxxxx>
- Date: Tue, 16 Aug 2016 12:49:52 -0700
- Cc: Brian Gerst <brgerst@xxxxxxxxx>, Baoquan He <bhe@xxxxxxxxxx>, Yinghai Lu <yinghai@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Thomas Garnier <thgarnie@xxxxxxxxxx>, Andy Lutomirski <luto@xxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, Alexander Kuleshov <kuleshovmail@xxxxxxxxx>, Josh Poimboeuf <jpoimboe@xxxxxxxxxx>, Christian Borntraeger <borntraeger@xxxxxxxxxx>, Stephen Smalley <sds@xxxxxxxxxxxxx>, "Kirill A. Shutemov" <kirill.shutemov@xxxxxxxxxxxxxxx>, Joerg Roedel <jroedel@xxxxxxx>, "Williams, Dan J" <dan.j.williams@xxxxxxxxx>, Mark Salter <msalter@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxx>, Jonathan Corbet <corbet@xxxxxxx>, Matt Fleming <matt@xxxxxxxxxxxxxxxxxxx>, Xiao Guangrong <guangrong.xiao@xxxxxxxxxxxxxxx>, "Aneesh Kumar K.V" <aneesh.kumar@xxxxxxxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, Toshi Kani <toshi.kani@xxxxxxx>, Alexander Popov <alpopov@xxxxxxxxxxxxxx>, Linux Kernel Mailing List <linux-kernel@xxxxxxxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Denys Vlasenko <dvlasenk@xxxxxxxxxx>, Peter Zijlstra <peterz@xxxxxxxxxxxxx>, Dave Young <dyoung@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Dmitry Vyukov <dvyukov@xxxxxxxxxx>, Lv Zheng <lv.zheng@xxxxxxxxx>, Martin Schwidefsky <schwidefsky@xxxxxxxxxx>, "linux-tip-commits@xxxxxxxxxxxxxxx" <linux-tip-commits@xxxxxxxxxxxxxxx>
- In-reply-to: <20160816175008.GA10538@nazgul.tnic>
- References: <1466556426-32664-7-git-send-email-keescook@chromium.org> <tip-021182e52fe01c1f7b126f97fd6ba048dc4234fd@git.kernel.org> <CAMzpN2h-CV2e1F_8u5GYkwaFkzoERfi9a83DEO7OeKEJB0RYTg@mail.gmail.com> <20160814232657.GA10704@x1.redhat.com> <CAMzpN2ixxOEonfgDdFRkB8P9Zb6eiFJF4Vx_HRMgWhm-7wK1hg@mail.gmail.com> <20160816134205.GB11106@nazgul.tnic> <20160816134928.GC11106@nazgul.tnic> <20160816155412.GB15004@nazgul.tnic> <20160816175008.GA10538@nazgul.tnic>
On Tue, Aug 16, 2016 at 10:50 AM, Borislav Petkov <bp@xxxxxxxxx> wrote:
> On Tue, Aug 16, 2016 at 05:54:12PM +0200, Borislav Petkov wrote:
>> Ok, I ran this in a guest and it finds the microcode patches properly.
>
> Here's a better version to take care of the APs too:
>
> ---
> diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
> index 27a0228c9cae..05242322e324 100644
> --- a/arch/x86/kernel/cpu/microcode/amd.c
> +++ b/arch/x86/kernel/cpu/microcode/amd.c
> @@ -355,6 +355,7 @@ void load_ucode_amd_ap(void)
> unsigned int cpu = smp_processor_id();
> struct equiv_cpu_entry *eq;
> struct microcode_amd *mc;
> + u8 *cont;
> u32 rev, eax;
> u16 eq_id;
>
> @@ -371,8 +372,12 @@ void load_ucode_amd_ap(void)
> if (check_current_patch_level(&rev, false))
> return;
>
> +#ifdef CONFIG_RANDOMIZE_MEMORY
> + cont = container + PAGE_OFFSET - __PAGE_OFFSET_BASE;
> +#endif
> +
> eax = cpuid_eax(0x00000001);
> - eq = (struct equiv_cpu_entry *)(container + CONTAINER_HDR_SZ);
> + eq = (struct equiv_cpu_entry *)(cont + CONTAINER_HDR_SZ);
Am I misreading this? Shouldn't it be:
cont = container;
#ifdef CONFIG_RANDOMIZE_MEMORY
cont += PAGE_OFFSET - __PAGE_OFFSET_BASE;
#endif
(otherwise cont is undefined in the RANDOMIZE_MEMORY=n case?)
>
> eq_id = find_equiv_id(eq, eax);
> if (!eq_id)
> @@ -434,6 +439,10 @@ int __init save_microcode_in_initrd_amd(void)
> else
> container = cont_va;
>
> +#ifdef CONFIG_RANDOMIZE_MEMORY
> + container += PAGE_OFFSET - __PAGE_OFFSET_BASE;
> +#endif
> +
> eax = cpuid_eax(0x00000001);
> eax = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
>
>
> --
> Regards/Gruss,
> Boris.
>
> ECO tip #101: Trim your mails when you reply.
> --
-Kees
--
Kees Cook
Nexus Security
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
[Index of Archives]
[Linux Stable Commits]
[Linux Stable Kernel]
[Linux Kernel]
[Linux USB Devel]
[Linux Video &Media]
[Linux Audio Users]
[Yosemite News]
[Linux SCSI]