Received: by 10.223.164.202 with SMTP id h10csp3472660wrb; Sat, 25 Nov 2017 09:21:49 -0800 (PST) X-Google-Smtp-Source: AGs4zMYPOkQ2foo/5Usi9pfWhC9SrlJVmLVHm0cjHYat2YB5j3EiMbCR230+tr/iwWUCiTxZ33DK X-Received: by 10.101.67.203 with SMTP id n11mr31537660pgp.228.1511630509003; Sat, 25 Nov 2017 09:21:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511630508; cv=none; d=google.com; s=arc-20160816; b=eFBw3cx+uPiFo+DMMXlGajs54HKMO8cW9Q2fQQAiO+GVpSS57GVDS7IoaRGqTH+q5P MStX17XBvGpv1VsBLPV0t8p0MNZ0tmgRAqU0fqRvifCVi4jxfUWkkLi9Z7j3LKreTlM3 6JcZmyP8mOzxwb8HKrUzbCUrDn7LbHLygHpBUv0MeYT8nRSC6MQ6l8Itm59lUosQEX8r so/zFtH243ggTHDkBBydy4NfQCSCHQvpAJYz2j4DKqis8gwU/nQXLiWtYKEzUo18yhW0 KDNHxESN3a7nT2Px4OxMRCFumJCXT7YCyyUfwCIWvBWygNurM2856UCM7tNJlKXa88vI aYbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature:arc-authentication-results; bh=qnMcW8TyDkPWOiSdaCah+6hzZ2nptIHcksBxofJw0/E=; b=jm22QOT55GYbcZX1RyRzG+pVBDaPIC+l+U9xTPjYuQztTzNLGh+XfGNj91lnGtGTpS le1GMSDF77V3SWp2B0UtLC9xiXQBMKPOE6xMCwZ4gwf4crTAOkKQ1bb3gs22Fxzo5kgt GjqXUzMDOlkc7RakOadX8hJmvkEh81kvuxtscgfU7CuJomFTCBgYg3H+Rrez2XkkXeUv Acav/P/YAxgIjN6kqUWOEcaRX+bvcfWsBhcNHh/xixzl1HAG3LNnZMfDRkvKBthFJg/7 WEISUWiw3BlxI5nuMpMn7R7V/xxv2/OmjRXX2VEro2Q08hh8T6Z0qxa8cE9ev3ijev11 mPKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ftxbch/9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h9si19861748pgq.740.2017.11.25.09.21.37; Sat, 25 Nov 2017 09:21:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ftxbch/9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751677AbdKYRU2 (ORCPT + 81 others); Sat, 25 Nov 2017 12:20:28 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35441 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbdKYRU1 (ORCPT ); Sat, 25 Nov 2017 12:20:27 -0500 Received: by mail-pg0-f67.google.com with SMTP id l19so16921997pgo.2; Sat, 25 Nov 2017 09:20:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=qnMcW8TyDkPWOiSdaCah+6hzZ2nptIHcksBxofJw0/E=; b=Ftxbch/9Jv3JtA7hN7XLJOcKDVs70/rcEeLpNEat2/LSXrF73C6hkrYubEcHnjX5Ad wqIEqgwo+2ohTicSKgoMQjgTWhro/OSR6y1wQgQMSp4esV97oZ+t9GbI/Zuzw9Yyk4P2 tIRbzawzS++v0pO9ujsdnhsVqAQEvzdRtZsBrjshJURYDxbbGrGyPvGIBbI2ViqoC5iE a/NkOpk3seckd7LsFFMuq7IhsberioFm2/qRETkruVSlKNN05rNw16Tc4x/e6ZoWKUUI eIh/9ynxCnOe5lIOEIfFfftXP9UGop33vmQLOMFgPJCkyxLdPyxP8hWtTfIUQreDJTVV u/Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=qnMcW8TyDkPWOiSdaCah+6hzZ2nptIHcksBxofJw0/E=; b=B0Un9sRYOvGrccSxPcn0zVfogCGh5lJWsfkmFJNbzJBFTGdsX+l3rNmpbW1t7D4eR9 2HJ/9OYP4BWS3rMm6LYpjIJYe+nOr4fLsiAAw8EEM8Qsasuq3TQfXFYh+sOO76N27C7h IwP4xk8MQfbsOLZ06C+V0LmOrhdEWoPwBxEYENZ4Bes/lvy+0NRoU9PtvSaQRfzdS9P1 dMrwRtx+Q1JwGMI17YBSJM9wbQ2uT/vs4S2+WsrBy0JYKaacaPK/pXQzgs8PqQ7SW+lw khQazlU2NCNDTxVNwFctGSl4jsVfTWw4AxTn9wEF125aPqKzx0umrDQAtcRDGCV7A1wR 0EdA== X-Gm-Message-State: AJaThX6/1wOHoI38UOZ7TEgJ4sA9vM3cN/uDOFQZioG7ppZchSnhYqJW eF6zNJ7mIhieMPrxr6bdh4M= X-Received: by 10.101.85.15 with SMTP id f15mr3981406pgr.63.1511630425990; Sat, 25 Nov 2017 09:20:25 -0800 (PST) Received: from [10.0.1.10] (c-24-23-137-57.hsd1.ca.comcast.net. [24.23.137.57]) by smtp.gmail.com with ESMTPSA id c185sm24491618pfb.48.2017.11.25.09.20.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Nov 2017 09:20:24 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH v2 2/2] x86: disable IRQs before changing CR4 From: Nadav Amit In-Reply-To: Date: Sat, 25 Nov 2017 09:20:23 -0800 Cc: LKML , linux-edac@vger.kernel.org, Andy Lutomirski , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Tony Luck , Borislav Petkov , Paolo Bonzini , =?utf-8?B?UmFkaW0gS3LEjW3DocWZ?= Content-Transfer-Encoding: quoted-printable Message-Id: <803D7D69-1F01-4CB8-A966-A040F302D1C0@gmail.com> References: <20171125032907.2241-1-namit@vmware.com> <20171125032907.2241-3-namit@vmware.com> To: Thomas Gleixner X-Mailer: Apple Mail (2.3273) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thomas Gleixner wrote: > On Fri, 24 Nov 2017, Nadav Amit wrote: >> /* Set in this cpu's CR4. */ >> -static inline void cr4_set_bits(unsigned long mask) >> +static inline void cr4_set_bits_irqs_off(unsigned long mask) >=20 > This change is kinda weird. I'd expect that there is a corresponding > function cr4_set_bits() which takes care of disabling interrupts. But = there > is not. All it does is creating a lot of pointless churn. >=20 >> static __always_inline void setup_smep(struct cpuinfo_x86 *c) >> static __init int setup_disable_smap(char *arg) >> static __always_inline void setup_pku(struct cpuinfo_x86 *c) >=20 > Why are you not doing this at the call site around all calls which = fiddle > with cr4, i.e. in identify_cpu() ? >=20 > identify_cpu() is called from two places: >=20 > identify_boot_cpu() and identify_secondary_cpu() >=20 > identify_secondary_cpu is called with interrupts disabled anyway and = there > is no reason why we can't enforce interrupts being disabled around > identify_cpu() completely. >=20 > But if we actually do the right thing, i.e. having cr4_set_bit() and > cr4_set_bit_irqsoff() all of this churn goes away magically. >=20 > Then the only place which needs to be changed is the context switch = because > here interrupts are already disabled and we really care about = performance. >=20 >> @@ -293,7 +303,7 @@ void __switch_to_xtra(struct task_struct *prev_p, = struct task_struct *next_p, >> } >>=20 >> if ((tifp ^ tifn) & _TIF_NOTSC) >> - cr4_toggle_bits(X86_CR4_TSD); >> + cr4_toggle_bits_irqs_off(X86_CR4_TSD); You make a good point. I will add cr4_set_bit(). I will leave = identify_cpu() as is, since it is rather hard to maintain code that enables/disables = irqs at one point and rely on these operations at a completely different = place. As you said, it is less of an issue once cr4_set_bit() and friends are introduced. Thanks, Nadav= From 1585034096978265460@xxx Sat Nov 25 10:38:28 +0000 2017 X-GM-THRID: 1585008173950843474 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread