From patchwork Mon May 20 23:19:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Garnier X-Patchwork-Id: 10952627 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDAE21395 for ; Mon, 20 May 2019 23:21:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB23B2624C for ; Mon, 20 May 2019 23:21:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98BD9288E4; Mon, 20 May 2019 23:21:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id C503E2624C for ; Mon, 20 May 2019 23:21:31 +0000 (UTC) Received: (qmail 3497 invoked by uid 550); 20 May 2019 23:20:28 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 3415 invoked from network); 20 May 2019 23:20:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7zcfl54ngcYZWe7SGjAVojGJkuuDkL2OOBnEHI8Zvuw=; b=d0sVux2H+Kp0vgnzWLkwaPIwsszW/blM2lWdjPDmAFb+mqIIG1s6CfAJxjwUcbjY6o fNLaPs6m1ivpVT8hWujSHn6V/uWK7/QnVmFz+fqPxMJVze0DAEF6km91b6qVleXbbxxt RAsVRk1pUchvj8zQPNU2JSeZCF/beeoFod/HU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7zcfl54ngcYZWe7SGjAVojGJkuuDkL2OOBnEHI8Zvuw=; b=BKXBGtpJo/6mhyDkaf9vLcKa/asdMB0N/pQrhRNU0IATn+R0VKhHL4VsERUcmQH0la 9v1yn7SzobPzJAUuiQCwe/MM7XOMaAowqFQ/MbappY7QZ2+b1LzwyVYBN9EVpvd2EuDL wmCiuQVUGiDqOG8r74R7hPchvQw5fNYW0s7ymiJiQuUko+RadALWqQ6zWaT6HLTk6ELD 1z0/S5EE9ot+DesNqTJv5Xwdr0apLO9iMV+gLVty4M7w0qhXv9ilsDj29x+kF6zoFvAN zKmZgidUD3dPDw597Tue1V1ntBYyEHv+yzPBZiConipj4e0W9DmEAuag4BK6LVM2vTUw hy8Q== X-Gm-Message-State: APjAAAUMcK4/wrVPHVC+frXWf5JNMKqhvo+w8STj+BUvwk/jyYTs/7Bi rEgz6Jgk0lzuVlKw+qxccqeuXTyP/34= X-Google-Smtp-Source: APXvYqyR5iFeDrOxrxE1hHhUIn+dH4BeM6Xeg5KaFIUtHRV7653rxOhVDxMaJjYMO0sQEPJqcLk2Sg== X-Received: by 2002:a17:902:e213:: with SMTP id ce19mr80568333plb.30.1558394415530; Mon, 20 May 2019 16:20:15 -0700 (PDT) From: Thomas Garnier To: kernel-hardening@lists.openwall.com Cc: kristen@linux.intel.com, Thomas Garnier , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , x86@kernel.org, Andrew Morton , Andi Kleen , Andy Lutomirski , linux-kernel@vger.kernel.org Subject: [PATCH v7 07/12] x86/CPU: Adapt assembly for PIE support Date: Mon, 20 May 2019 16:19:32 -0700 Message-Id: <20190520231948.49693-8-thgarnie@chromium.org> X-Mailer: git-send-email 2.21.0.1020.gf2820cf01a-goog In-Reply-To: <20190520231948.49693-1-thgarnie@chromium.org> References: <20190520231948.49693-1-thgarnie@chromium.org> MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP From: Thomas Garnier Change the assembly code to use only relative references of symbols for the kernel to be PIE compatible. Use the new _ASM_MOVABS macro instead of the 'mov $symbol, %dst' construct. Position Independent Executable (PIE) support will allow to extend the KASLR randomization range below 0xffffffff80000000. Signed-off-by: Thomas Garnier --- arch/x86/include/asm/processor.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index c34a35c78618..5490a6ead17c 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -710,11 +710,13 @@ static inline void sync_core(void) "pushfq\n\t" "mov %%cs, %0\n\t" "pushq %q0\n\t" - "pushq $1f\n\t" + "movabsq $1f, %q0\n\t" + "pushq %q0\n\t" "iretq\n\t" UNWIND_HINT_RESTORE "1:" - : "=&r" (tmp), ASM_CALL_CONSTRAINT : : "cc", "memory"); + : "=&r" (tmp), ASM_CALL_CONSTRAINT + : : "cc", "memory"); #endif }