Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp525028iof; Mon, 6 Jun 2022 07:56:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxvqaORiiBhoTP4JNLvXG9e15FU1njrQLKJqjoZsEBoCwcAXJQFqlO6UjBws+Jt3U9rkVy X-Received: by 2002:a17:902:a981:b0:156:52b2:40d6 with SMTP id bh1-20020a170902a98100b0015652b240d6mr24557213plb.34.1654527372667; Mon, 06 Jun 2022 07:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654527372; cv=none; d=google.com; s=arc-20160816; b=QQaodf+jDSJZQcRFGt3G9h21fR25t0+R3xVHoBWuWuB1KTGRdrkjZb6tlvmjI78TR8 C3neXyNhjtobX0fX34XT42xivEXguHpfWv3kYyoBJFs+Mrbdr0lrS0HB/ZBnap3fFzui 1ZCeIV96FCvJut2GCi47FJEubHUaVuY4ltrsOXyun/3iEmcQvGD7sGAF7iGRA82jrAEv FCtpjYlB7EK5Pn+cY9EyglbzceF2RFJNEd3/bUDcF9b1xl0syOBiWQPEAwgfjsR0Sf+r W//BuTaWaQhlzDrZaCDwv+wFilCzSeqTfkkt0kvpuJUsBw2edEm7TGaKBSkVLbdZknts GWhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=J0AjupS423IcVxPOF8+Ias71Zs7GJnxkL456RKcGoI4=; b=DqEHMXLlvExQH1NWZf4DM2IMRf0HMEe+5QEj6KRCEJPRAPgODw60m2fQo8oYfzVPb0 qOK6MlXmXNAnDATPp5qLVxHlIVcu2fJ5PPN45IUt/+Gh33Z6tT+t6blU9XFM5WPWZUDo kt8kbHLM+QTsQAaa07uorGuXSaU0v3hG/VNAKqBpJ3KtPsH7/H9Skhg0dycHvsMOMrdA qb50aQIFVn46EgRsgKy+tTh/WQJI8OtM1exqTL0gf4laBUizvqNbI0vWPE1YJVPxSZ/2 dkQYIlQgMUW2lF+Wnoixhx+nl8YRrbv9lHA6g/36Mtl7ORZ8mmyI4eRYYAUe1/OKTVWW NEGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N96+7PHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pi15-20020a17090b1e4f00b001e85049e709si12859117pjb.72.2022.06.06.07.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jun 2022 07:56:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=N96+7PHU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3074F50B3C; Mon, 6 Jun 2022 07:44:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239909AbiFFOoh (ORCPT + 99 others); Mon, 6 Jun 2022 10:44:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239823AbiFFOo3 (ORCPT ); Mon, 6 Jun 2022 10:44:29 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BC235000A for ; Mon, 6 Jun 2022 07:44:28 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id w13-20020a17090a780d00b001e8961b355dso853770pjk.5 for ; Mon, 06 Jun 2022 07:44:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=J0AjupS423IcVxPOF8+Ias71Zs7GJnxkL456RKcGoI4=; b=N96+7PHU+aEx81sVHh6CFec/XmlIA4EYXB8GPuNvzQ3gFS/MAzcwvGBdtU9oazZzf1 lccNpukP/evxop0gpJssxdVvPC9+FW3LTlYWGsH0ZPzP4xGQiXDrpiLlqt5sZPtK9mJk r+w//DfnS8SM51tMbLkhxRwk8EhRSh+VRG1O9xhKZTW9x2qn94N0BV6ITq9sez5z/lXi D/HPH7EYhHxDwrEJKezy3M74vUGaidaXI2jrhgRQsnCcYLYG9riapBkGIOY7vVb5R2t1 zDeszG5J/d4BvkgNfviauw+gb5lqRwwimAwuG3WEpYeNHRVmitVkhiurdWJbqqmemRRw utcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J0AjupS423IcVxPOF8+Ias71Zs7GJnxkL456RKcGoI4=; b=T3qd5RkctF9zHaRVjrvThSOkmqRfRTJJ7l+DLDAPcIu6p/jDFgNGbX/KYt+QucBG7z Q6MNHxkR5ZJiWWqWQOWRBqMdKWGBi0c6hXc7EoF4JmpchYii/LKggYOIZKrdz/HYA8Zf qtuc0+5bCCaQe8bL5ohsOYSWmM1JcGPQlulypvtmUEwXy6JG0tTHghTXM2QQ+a1lYJcV WQZ9iYcbcYHu/aT5VCyXjESNqNwZGfYc7mdW4jz9AT3J7pKayTjZbxqsgX2aigwWM7Pa Cf68GH0ssJhrFQzaq85BP6BUJ8Q9wdN4EoF3LGA+nGwgPlc5KLCmmd2ToZ+Q0Q7ClmcD Wbvg== X-Gm-Message-State: AOAM530rWY/BYPCYq8JZlpIJUnfACmXG4iBaVoZVjKML2POBzeIlLngA eaLLIqEIc2WP0XJlgMpEdWKvqVHe3Pw= X-Received: by 2002:a17:90a:9f04:b0:1e3:2d77:3eae with SMTP id n4-20020a17090a9f0400b001e32d773eaemr38454049pjp.243.1654526667932; Mon, 06 Jun 2022 07:44:27 -0700 (PDT) Received: from localhost ([198.11.178.15]) by smtp.gmail.com with ESMTPSA id q14-20020a170902eb8e00b001615f64aaabsm6200271plg.244.2022.06.06.07.44.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jun 2022 07:44:27 -0700 (PDT) From: Lai Jiangshan To: linux-kernel@vger.kernel.org Cc: Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Andy Lutomirski , Thomas Gleixner , x86@kernel.org, Lai Jiangshan , Ingo Molnar , Dave Hansen , "H. Peter Anvin" , Sean Christopherson , Joerg Roedel , "Kirill A. Shutemov" , Miguel Ojeda , Kees Cook , Nathan Chancellor , Andrew Morton , Alexei Starovoitov , Marco Elver , Hao Luo , Nick Desaulniers , Rasmus Villemoes Subject: [PATCH V3 1/7] x86/entry: Introduce __entry_text for entry code written in C Date: Mon, 6 Jun 2022 22:45:03 +0800 Message-Id: <20220606144509.617611-2-jiangshanlai@gmail.com> X-Mailer: git-send-email 2.19.1.6.gb485710b In-Reply-To: <20220606144509.617611-1-jiangshanlai@gmail.com> References: <20220606144509.617611-1-jiangshanlai@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lai Jiangshan Some entry code will be implemented in C files. Introduce __entry_text to set them in .entry.text section. The new __entry_text disables instrumentation like noinstr, so __noinstr_section() is added for noinstr and the new __entry_text. Note, entry code can not access to %gs before the %gs base is switched to kernel %gs base, so stack protector can not be used on the C entry code. But __entry_text doesn't disable stack protector since some compilers might not support function level granular attribute to disable stack protector. It will be disabled in C file level. Cc: Borislav Petkov Reviewed-by: Miguel Ojeda Reviewed-by: Kees Cook Suggested-by: Nick Desaulniers Suggested-by: Peter Zijlstra Signed-off-by: Lai Jiangshan --- arch/x86/include/asm/idtentry.h | 3 +++ include/linux/compiler_types.h | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/x86/include/asm/idtentry.h b/arch/x86/include/asm/idtentry.h index 72184b0b2219..acc4c99f801c 100644 --- a/arch/x86/include/asm/idtentry.h +++ b/arch/x86/include/asm/idtentry.h @@ -13,6 +13,9 @@ #include +/* Entry code written in C. */ +#define __entry_text __noinstr_section(".entry.text") + /** * DECLARE_IDTENTRY - Declare functions for simple IDT entry points * No error code pushed by hardware diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index d08dfcb0ac68..bd9d9d19dc9b 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -225,9 +225,11 @@ struct ftrace_likely_data { #endif /* Section for code which can't be instrumented at all */ -#define noinstr \ - noinline notrace __attribute((__section__(".noinstr.text"))) \ - __no_kcsan __no_sanitize_address __no_profile __no_sanitize_coverage +#define __noinstr_section(section) \ + noinline notrace __section(section) __no_kcsan \ + __no_sanitize_address __no_profile __no_sanitize_coverage + +#define noinstr __noinstr_section(".noinstr.text") #endif /* __KERNEL__ */ -- 2.19.1.6.gb485710b