From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227K7DzGy6j+n7tcyWNoFe0ZrbIv8X9G0QVcEsv63Rt3kY2hW/PDz3AlDp+KdXy/0JpC2mSS ARC-Seal: i=1; a=rsa-sha256; t=1516721578; cv=none; d=google.com; s=arc-20160816; b=A83LN/o7a2QKO/7YLQAzFJ2qziFIIwFcC2L1JjVzkMiHu5enpCCdd/SiNgdDeGJevb wss4mr1TFOoV8w3E292FArAMiAdj0hJQ0RKy1PuIVd3IYPzyMq5uhTG/FacWy91y4HEB 3+f3Pv+NAYVPaJC1Rc7IscsRGxztEuRQHU+iu27B+f1AIBtXiXzyT4F1061tkUkXyF2d vJGMXP2i1VswofAiMwiQfeKrOFdWPswP/bE2zQOe6yacrj425P/HCEsBlElppqbBlvOp fiM8v9NzNrMoTZOL1/pgPRFbA4LPLJcZzGA7kGpC1+vYAED906mY0+SmrsoVXQiu/J7x r1PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature:arc-authentication-results; bh=rfpjGav+lGhClLZgtW54BrpGlO56KMb+hU/N4H8nt2w=; b=TWPqlIFpiN3zu4TaLrGHw6Wq7Zu8P59zZ28DBNcDfKFLkTx4nt85wEc9c0z7h5AN1p gniRsDy2xjnhfU3m2gc7ZjHwY1M2bWTZOSHzIGy1sLBjWRMaaPPfW64UY2IL8QFOFKsw l/Y3VuNmMCC65UPvLH5UG02p7qgcgRRzzjIQTDqjGbqWErNtjx1aSC8yXUFolUnF54cz ftuyu0ziZPbEbg0YvEQC0N+kp1PRrq8eJy4doxsezjdb4+wn/YZG7UD2qXPe/RBVBWBF /xOKRrZSXwb5Rj9E0I5Eyw8lmFMn2oyslLa1kRkomuu930IYJjtmWDuAseTzB2mFpcee 3cGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=j984GOaf; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=j984GOaf; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=peterz@infradead.org Message-Id: <20180123152638.875497319@infradead.org> User-Agent: quilt/0.63-1 Date: Tue, 23 Jan 2018 16:25:54 +0100 From: Peter Zijlstra To: David Woodhouse , Thomas Gleixner , Josh Poimboeuf Cc: linux-kernel@vger.kernel.org, Dave Hansen , Ashok Raj , Tim Chen , Andy Lutomirski , Linus Torvalds , Greg KH , Andrea Arcangeli , Andi Kleen , Arjan Van De Ven , Dan Williams , Paolo Bonzini , Jun Nakajima , Asit Mallick , Jason Baron , Peter Zijlstra , Borislav Petkov Subject: [PATCH 15/24] x86: Annotate static_cpu_has alternative References: <20180123152539.374360046@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline; filename=peterz-x86-static_cpu_has-annotate.patch X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590397846213683722?= X-GMAIL-MSGID: =?utf-8?q?1590397846213683722?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: In order to recognise static_cpu_has() alternatives from any other alternative without dodgy heuristics, we need to explicitly mark them. Use the new type field for this. Reviewed-by: Borislav Petkov Signed-off-by: Peter Zijlstra (Intel) --- arch/x86/include/asm/alternative.h | 6 ++++++ arch/x86/include/asm/cpufeature.h | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -47,6 +47,12 @@ #define ALT_TYPE_DEFAULT 0 +/* + * This alt_instr descriptor is part of a static_cpu_has() construct. Use it to + * detect its type when processing with other tools, like objtool, for example. + */ +#define ALT_TYPE_STATIC_CPU_HAS 1 + struct alt_instr { s32 instr_offset; /* original instruction */ s32 repl_offset; /* offset to replacement instruction */ --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -157,7 +157,7 @@ static __always_inline __pure bool _stat " .byte 3b - 1b\n" /* src len */ " .byte 5f - 4f\n" /* repl len */ " .byte 3b - 2b\n" /* pad len */ - " .byte 0\n" /* type */ + " .byte %P[type]\n" /* type */ ".previous\n" ".section .altinstr_replacement,\"ax\"\n" "4: jmp %l[t_no]\n" @@ -170,7 +170,7 @@ static __always_inline __pure bool _stat " .byte 3b - 1b\n" /* src len */ " .byte 0\n" /* repl len */ " .byte 0\n" /* pad len */ - " .byte 0\n" /* type */ + " .byte %P[type]\n" /* type */ ".previous\n" ".section .altinstr_aux,\"ax\"\n" "6:\n" @@ -181,6 +181,7 @@ static __always_inline __pure bool _stat : : [feature] "i" (bit), [always] "i" (X86_FEATURE_ALWAYS), [bitnum] "i" (1 << (bit & 7)), + [type] "i" (ALT_TYPE_STATIC_CPU_HAS), [cap_byte] "m" (((const char *)boot_cpu_data.x86_capability)[bit >> 3]) : : t_yes, t_no); t_yes: