Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1833121ybk; Mon, 11 May 2020 05:30:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5bKyjFseMPMq6V4Ma8dyl9UELr03Komdg6FnEGAPYEb8uspzjSrjGyVFwhAeFFgcubzqB X-Received: by 2002:a50:bf04:: with SMTP id f4mr4663161edk.91.1589200209077; Mon, 11 May 2020 05:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589200209; cv=none; d=google.com; s=arc-20160816; b=V+qkTVwqmAMsBXB+I5RBCXR2ngHa8q2yN7RnSrZH4LvKW/Ku2fPEzr37Nlwm3Vtjpl sPJ/yYnT5J7SY3tnkXO+tnnOaNoWWecNVlfGryxTLnghvD+LNikcVqQnqP2wNVPVaZSD Cz8H4Wiu3orvofFAquxopejpgjuJ8sNmT6VTyqG/0mBjv/rhYmgpAT2kX6E0ebd81zoR 3cAHktg90/cJh6qt9/TxwlyZD9ymPAuF/uhWcEN5g+dhiVcUx3rehhrisU+75DtHW8HN nmU4RZQrfN/SAoNvDppWVLFSjq0sypap9tha4YZjgKu5RrEBeuv+UCwj5uYRGuIMRU/k +fjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=p6RMQryBRVi4I+EM2QX0UcN7IOgEFnMbi7lzfNoFI9E=; b=xRU+O/qz4DQYE4acqVapuyz8L4vjQz/p4JdDE1dJo7v4VeSnTC4/7jCIxb9Nw4iv+q znQTNYj8BIim330T5Bu33qAEuQyoEJvwJNr9vZF9WqwU+6HuZGrHRR9HI8xwYQxYSa4B ZIuxnAveTooDNgBLz+4Rybn6IzbVwsqo+Bb5UpNkbvo0CBfWJUoSQJJurhNoes8qxeyU kvpZCQiv3F01zQr/ZbHZN8LvmF1E0kDC/rf1lGHLhf5UlGw+nj+M7NIAsUu5FVoWWKIu AtcgskL4fwjpxdLLJgIyOoKYHIGdX16TAzknBsJ4zD25NPBOg8AYTBGx3rMw4ho6kn40 muMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rfxtQxF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si5815392edf.183.2020.05.11.05.29.46; Mon, 11 May 2020 05:30:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rfxtQxF6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729595AbgEKM2Y (ORCPT + 99 others); Mon, 11 May 2020 08:28:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:60322 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729343AbgEKM2X (ORCPT ); Mon, 11 May 2020 08:28:23 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF3DD207FF; Mon, 11 May 2020 12:28:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589200103; bh=1NdyNA3J3Yq4GF6v9HalR4dr/LL5h+c+E7CSWgyAJww=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=rfxtQxF6apz0ygIr6KQOAkFJKCNLaGsSrSwuFhYvY/mcLyTLsIjIsg3yWlbR4UDDy M4RYPvXRkt5uQcSJK5qOuSlCu5nTorzwImpjTDJ5Z6Vel/JcnzUknK8/326bRp1V8+ iimbdr1FUeE2E7LZsIqXUzz6FeTZD1DCc7EfoDfk= Date: Mon, 11 May 2020 21:28:16 +0900 From: Masami Hiramatsu To: Thomas Gleixner Cc: LKML , x86@kernel.org, "Paul E. McKenney" , Andy Lutomirski , Alexandre Chartre , Frederic Weisbecker , Paolo Bonzini , Sean Christopherson , Masami Hiramatsu , Petr Mladek , Steven Rostedt , Joel Fernandes , Boris Ostrovsky , Juergen Gross , Brian Gerst , Mathieu Desnoyers , Josh Poimboeuf , Will Deacon Subject: Re: [patch V4 part 3 01/29] x86/traps: Mark fixup_bad_iret() noinstr Message-Id: <20200511212816.45516d0e9e72c1ea543b0a36@kernel.org> In-Reply-To: <20200505134903.346741553@linutronix.de> References: <20200505134354.774943181@linutronix.de> <20200505134903.346741553@linutronix.de> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 05 May 2020 15:43:55 +0200 Thomas Gleixner wrote: > This is called from deep entry ASM in a situation where instrumentation > will cause more harm than providing useful information. > > Signed-off-by: Thomas Gleixner Looks good to me. Reviewed-by: Masami Hiramatsu Thank you, > --- > arch/x86/kernel/traps.c | 16 +++++++++------- > 1 file changed, 9 insertions(+), 7 deletions(-) > > --- a/arch/x86/kernel/traps.c > +++ b/arch/x86/kernel/traps.c > @@ -621,7 +621,7 @@ struct bad_iret_stack { > struct pt_regs regs; > }; > > -asmlinkage __visible notrace > +asmlinkage __visible noinstr > struct bad_iret_stack *fixup_bad_iret(struct bad_iret_stack *s) > { > /* > @@ -632,19 +632,21 @@ struct bad_iret_stack *fixup_bad_iret(st > * just below the IRET frame) and we want to pretend that the > * exception came from the IRET target. > */ > - struct bad_iret_stack *new_stack = > - (struct bad_iret_stack *)this_cpu_read(cpu_tss_rw.x86_tss.sp0) - 1; > + struct bad_iret_stack tmp, *new_stack = > + (struct bad_iret_stack *)__this_cpu_read(cpu_tss_rw.x86_tss.sp0) - 1; > > - /* Copy the IRET target to the new stack. */ > - memmove(&new_stack->regs.ip, (void *)s->regs.sp, 5*8); > + /* Copy the IRET target to the temporary storage. */ > + memcpy(&tmp.regs.ip, (void *)s->regs.sp, 5*8); > > /* Copy the remainder of the stack from the current stack. */ > - memmove(new_stack, s, offsetof(struct bad_iret_stack, regs.ip)); > + memcpy(&tmp, s, offsetof(struct bad_iret_stack, regs.ip)); > + > + /* Update the entry stack */ > + memcpy(new_stack, &tmp, sizeof(tmp)); > > BUG_ON(!user_mode(&new_stack->regs)); > return new_stack; > } > -NOKPROBE_SYMBOL(fixup_bad_iret); > #endif > > static bool is_sysenter_singlestep(struct pt_regs *regs) > -- Masami Hiramatsu