From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966386AbbBCSRE (ORCPT ); Tue, 3 Feb 2015 13:17:04 -0500 Received: from mail.skyhub.de ([78.46.96.112]:60131 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756087AbbBCSQ5 (ORCPT ); Tue, 3 Feb 2015 13:16:57 -0500 From: Borislav Petkov To: X86 ML Cc: LKML Subject: [PATCH v1 00/12] x86, alternatives: Instruction padding and more robust JMPs Date: Tue, 3 Feb 2015 19:16:18 +0100 Message-Id: <1422987390-17878-1-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.2.0.33.gc18b867 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Borislav Petkov [ Changelog is in version-increasing number so that one can follow the evolution of the patch set in a more natural way (i.e., latest version comes at the end. ] v0: this is something which hpa and I talked about recently: the ability for the alternatives code to add padding to the original instruction in case the replacement is longer and also to be able to simply write "jmp" and not care about which JMP exactly the compiler generates and whether the relative offsets are correct. So this is a stab at it, it seems to boot in kvm here but it needs more staring to make sure we're actually generating the proper code at all times. Thus the RFC tag, comments/suggestions are welcome. v1: This is the first version which passes testing on AMD/Intel, 32/64-bit boxes I have here. For more info what it does, you can boot with "debug-alternative" to see some verbose information about what gets changed into what. Patches 1 and 2 are cleanups. Patch 3 is adding the padding at build time and patch 4 simplifies using JMPs in alternatives without having to do crazy math with labels, as a user of the alternatives facilities. Patch 5 optimizes the single-byte NOPs we're adding at build time to longer NOPs which should go easier through the frontend. Patches 6-12 then convert most of the alternative callsites to the generic macros and kill the homegrown fun. As always, constructive comments/suggestions are welcome. Borislav Petkov (12): x86, copy_user: Remove FIX_ALIGNMENT define x86, alternatives: Cleanup DPRINTK macro x86, alternatives: Add instruction padding x86, alternatives: Make JMPs more robust x86, alternatives: Use optimized NOPs for padding x86, copy_page_64.S: Use generic ALTERNATIVE macro x86, copy_user_64.S: Convert to ALTERNATIVE_2 x86, SMAP: Use ALTERNATIVE macro x86, alternative: Convert X86_INVD_BUG to generic macro x86, alternatives: Convert clear_page_64.S x86, alternative: Use alternative_2 in rdtsc_barrier x86, alternative: Cleanup prefetch primitives arch/x86/include/asm/alternative-asm.h | 40 ++++++++ arch/x86/include/asm/alternative.h | 58 +++++++----- arch/x86/include/asm/apic.h | 2 +- arch/x86/include/asm/barrier.h | 6 +- arch/x86/include/asm/cpufeature.h | 23 ++--- arch/x86/include/asm/processor.h | 16 ++-- arch/x86/include/asm/smap.h | 30 ++---- arch/x86/kernel/alternative.c | 164 ++++++++++++++++++++++++++++----- arch/x86/kernel/cpu/amd.c | 5 + arch/x86/kernel/entry_32.S | 12 +-- arch/x86/lib/clear_page_64.S | 66 ++++++------- arch/x86/lib/copy_page_64.S | 37 +++----- arch/x86/lib/copy_user_64.S | 46 ++------- arch/x86/um/asm/barrier.h | 4 +- 14 files changed, 305 insertions(+), 204 deletions(-) -- 2.2.0.33.gc18b867