From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751930AbeAJU02 (ORCPT + 1 other); Wed, 10 Jan 2018 15:26:28 -0500 Received: from mail-it0-f47.google.com ([209.85.214.47]:43591 "EHLO mail-it0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751545AbeAJU01 (ORCPT ); Wed, 10 Jan 2018 15:26:27 -0500 X-Google-Smtp-Source: ACJfBot9w8wTcf+SMDO7hxQsHxKRURtNqfXzS2DHdaDV56d7uFpxc/ezUiYCaSO9PJ/RPzVj8x8FXU5+LObJ7J1n4gU= MIME-Version: 1.0 In-Reply-To: <20180110201532.5jnji6ypfl6slzvb@treble> References: <20180110003139.10531-1-andi@firstfloor.org> <1515568506.22302.72.camel@infradead.org> <1515578735.22302.91.camel@infradead.org> <20180110112815.mgciyf5acwacphkq@pd.tnic> <20180110201532.5jnji6ypfl6slzvb@treble> From: Linus Torvalds Date: Wed, 10 Jan 2018 12:26:25 -0800 X-Google-Sender-Auth: vHv-QKY0EcuX7P1_HQqaB9uLxHU Message-ID: Subject: Re: [PATCH] x86/alternatives: Fix optimize_nops() checking To: Josh Poimboeuf Cc: Thomas Gleixner , Borislav Petkov , David Woodhouse , Andi Kleen , "the arch/x86 maintainers" , Linux Kernel Mailing List , Paul Turner , Andrew Lutomirski , Peter Zijlstra , Tom Lendacky , Tim Chen , Greg Kroah-Hartman , Dave Hansen , Jiri Kosina , Andi Kleen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, Jan 10, 2018 at 12:15 PM, Josh Poimboeuf wrote: > > I think .altinstruction relocations *do* work if they're for the first > instruction, and it's a jump or a call. Yes - for the alternative that is in-line - not in the "altinstruction" section. Because then the alternative is in the right spot at link-time already. But the "altinstruction" section definitely should not have relocations. I guess you could hack them up by hand by explicitly trying to take the difference between the non-altinstruction and the altinstruction into account, but it would be error-prone and fragile as hell. > I think Boris had a patch floating around to add an instruction decoder > to alternatives, so you can do a call/jmp anywhere. .. and no, we're not doing that. Christ. People, we need to try to be *robust* here. That's doubly (triply!) true of things like altinstructions where people - very much by design - won't even *test* the alternatives very much, because very much by design the altinstructions are only used on certain architectures or in certain situations. And we almost certainly don't actuially _need_ relocations. But we need to protect against the "oops, I didn't realize" issue, exactly because testing won't actually catch the odd cases. Because we don't want to be in the situation where some random poor user hits it because they have an old CPU that no developer has, and then the relocation will basically do completely random things. Imagine just how crazy that would be to debug. You'd be basically executing insane code, and looking at the sources - or even the binaries - it would _look_ completely sane. Linus