From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227upJM3IngFTLcBeel6GGHp88cbHEeWuezn1tdfuklfqNQcFFtL3ZKo2CYcMABpCM9FPfQN ARC-Seal: i=1; a=rsa-sha256; t=1516872917; cv=none; d=google.com; s=arc-20160816; b=C3i14ys/6cx/ybHLcDs1nQDYVPDk6nVj2SNWsPiT5b92+dNjH5tDVBJMY3O5AiFYAs tjE9af9rhuU7AW8k7r661YMXkpabZvQnCDTNh1oI36/6+2ZP6jw/IPsr0azURIgS9CtA yws0/fsDm9o5K7D7vvoBE8p5Z6b4wKTCq0oEtQ/gjUSAb0Ok6KAnSwFoHC4hVE2LEk9K qGgzH3C4CE+0mklNPhiBnYbsCLeJrmR9vbDXug3u/4hkYiJFYvWsfE3FtFozWkcMTkv4 WDBC99aPycfBsVKSls1U7O7LHXVHTLRweddkVYIyGWGwKfsA+K006xkd12W9UUrqNvDz Jyng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=LoXonX2xS1c8ZmtZ4TNa7RO2NaKpDa53q090gXvYsIw=; b=TUaHoG73e3O3koBI7owg8eSno8ciN69Ed1i1f5p1HFnxTMlTl5UwrUpjrg95cxcHLx S6OzRBhszL/BMGclf9mJnKioT8B5ETuJBeCEvssbe81qy4RS9ymsWhHh3pDpNVgm8w5R YphR/kW1YTLNe5EXIv5EfWbCMxZwScnOUSYeGppbLZ9zMjG2oV7ULx7cBPH6aLs/wQbn al+P3dETd7Ox7MXJgTRtxV9zJoai4pIWvwB6F63ftyCff9u3bIbA1FAZOhX7xJIiVPup LQZjL7GvOYSLCxx7u7QlVSDZ8Bs2zn9XJ3P6R7/4J79qTk8ySka+DRyKi4++UCMQfafd /GkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=b/upgmlR; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=merlin.20170209 header.b=b/upgmlR; spf=pass (google.com: best guess record for domain of peterz@infradead.org designates 205.233.59.134 as permitted sender) smtp.mailfrom=peterz@infradead.org Date: Thu, 25 Jan 2018 10:34:53 +0100 From: Peter Zijlstra To: Paolo Bonzini Cc: David Woodhouse , Borislav Petkov , Thomas Gleixner , Josh Poimboeuf , 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 , Jun Nakajima , Asit Mallick , Jason Baron Subject: Re: [PATCH 06/24] x86,kvm: Fix indirect calls in emulator Message-ID: <20180125093453.GX2228@hirez.programming.kicks-ass.net> References: <20180123152539.374360046@infradead.org> <20180123152638.336674335@infradead.org> <20180123202859.qc5frxyonavtkhpz@pd.tnic> <1516740493.13558.3.camel@infradead.org> <20180124103525.GR2228@hirez.programming.kicks-ass.net> <9fe90910-7908-f570-0088-568213f52a78@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9fe90910-7908-f570-0088-568213f52a78@redhat.com> User-Agent: Mutt/1.9.2 (2017-12-15) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590397846081548237?= X-GMAIL-MSGID: =?utf-8?q?1590556536320917679?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: On Wed, Jan 24, 2018 at 11:43:05AM +0100, Paolo Bonzini wrote: > On 24/01/2018 11:35, Peter Zijlstra wrote: > > On Tue, Jan 23, 2018 at 08:48:13PM +0000, David Woodhouse wrote: > >> On Tue, 2018-01-23 at 21:28 +0100, Borislav Petkov wrote: > >>> > >>>>        flags = (flags & EFLAGS_MASK) | X86_EFLAGS_IF; > >>>> -     asm("push %[flags]; popf; call *%[fastop]" > >>>> -         : "=a"(rc) : [fastop]"r"(fop), [flags]"r"(flags)); > >>>> +     asm("push %[flags]; popf; " CALL_NOSPEC > >>>> +         : "=a"(rc) : [thunk_target]"r"(fop), [flags]"r"(flags)); > >>> > >>> Oh, "thunk_target" is magical. > >> > >> You can use THUNK_TARGET(fop), which will be "rm" on 32-bit and avoids > >> register starvation in some cases (I don't think the hyperv calls > >> worked until I did that). > > > > The reason I didn't use THUNK_TARGET() was exactly because it used "rm" > > and the current code did "r" only. I'm happy to change if people can > > agree on something ;-) > > In practice, "fastop" is going to be in a register because of how it's > computed, but "rm" is okay. OK, so the other occurence in that file uses "+S", which is the SI register. That cannot use THUNK_TARGET(), right? So do you want one THUNK_TARGET and one open coded, or keep the patch as is (both open coded) ?