Received: by 10.223.164.202 with SMTP id h10csp3480447wrb; Sat, 25 Nov 2017 09:31:58 -0800 (PST) X-Google-Smtp-Source: AGs4zMYZMaNqzQFVlBlze/sqMyYWKneciZ87TJj+quA1I7AR7yJ4+/fRH6Ip00qiuUht4N0ANCeQ X-Received: by 10.84.172.1 with SMTP id m1mr33351006plb.345.1511631117967; Sat, 25 Nov 2017 09:31:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511631117; cv=none; d=google.com; s=arc-20160816; b=lX6G0OLlD/pcTcGNfnqEPQR2UhzqDl3JWqB8aaFO/AVv7pFJnnTfuJBak6UPQ5vCoa KJpLIaQ4ogE8IhN+tEIDfeISoOVxrFMqRWdjJLkQ7xIP9AgEWatIvxmE9nBd0Y5gNO8G Ys+3W6tnF8feqRqYDMmDjoPKmTYrhmCUJFSh4uROONuUwuvi9RP8EwfiTsIeQqbANHny IsEakpoJxRTQmwDXz1NJsd9gZZ5zue/3QB0Vg+YfxbmanQGfChErZ+dSa6/Zn1EkGrsO B0ZM/Srcb7RWfiK7cleF6j3FYUYGz4ZAabyhqZg2FbfPCvaH2uUgfkbRMfzrGOgBfDgm YNsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:to:cc:in-reply-to:date:subject :mime-version:message-id:from:dkim-signature :arc-authentication-results; bh=r6dQZKsg9fkQV/eUVM1k+UZLdpRlxkDIHvputvihieY=; b=U+D91CFHcw/kYulumJ1fEgi8xAeaiQIm+k4BBozoau4jDevI4FKpzRN9oRUNIYQ77q BAxHQrSginWJYgmwRFU9rnBGOdAu5g0otaQWgOuDXcm/3+XGgSHtX4a7SPvi0ym1xPGr vRGqpHim2NzVS19ifH6n6+TCYvQaT7OvSzjq/SvkKmNKPZz/RtCMT7dmk2w1g+hDrJ1d hUgM62OJ0RcPZrIt8feFSbHG9rPzzgwsjhIpNmA5IxsnBPwfR06MPQR0jUlXgA55Dbdt GE3pFtD6TwqODOpR2Z3EJVe76s3XW6H64gAycCDedzHpl6ZkuVGBIaPIUOGBjwkQMbxo kXUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=efa5Ix2E; 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 j18si20048323pgn.474.2017.11.25.09.31.45; Sat, 25 Nov 2017 09:31:57 -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=efa5Ix2E; 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 S1751635AbdKYRbJ (ORCPT + 81 others); Sat, 25 Nov 2017 12:31:09 -0500 Received: from mail-qk0-f196.google.com ([209.85.220.196]:37181 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751277AbdKYRbH (ORCPT ); Sat, 25 Nov 2017 12:31:07 -0500 Received: by mail-qk0-f196.google.com with SMTP id 136so27840235qkd.4; Sat, 25 Nov 2017 09:31:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=r6dQZKsg9fkQV/eUVM1k+UZLdpRlxkDIHvputvihieY=; b=efa5Ix2E2zo8dzMkJkTsSDYZYjJLnMdVtJW9x87wyf278+kh0Oc2ImNFBf84XSgBKv bfaAu8PTEbdKCP/+l7Qe4k1KMQLHy8SLTZOZS5FeDInYpAQObW2Fbv2RrfAdxoQcm3pd Ep72hlGFmdaFsO0NGNhejExBpJWzVwW4u0SPIEijxLW1Z2B5YGZsHTB5c4E6NgsTOai5 5F+r4eDXM9sLcnKuc9jRneAWtwAvGHFQ0sTSmqfCmgpls72lWi80MvwQcaoS8s9p1ICV Sjf+jHjKHC8SlokQIfiasjYukCQgIsSD7QHaAjqMjugqJ+souc/8toe0ztMz8Cesdn+x 2p0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=r6dQZKsg9fkQV/eUVM1k+UZLdpRlxkDIHvputvihieY=; b=P2HfXd2Xd2UbBo+wSOVklf8n0YSx0zytyaRA1q4WEyLEHCYsVYNS97YFYP0cAdlRVo 7dHNuiS6vVtA+1EzCYWcuHNmDtJoncAnmRBomDfyJ1yeeg1rUJiYxsFaCOwfPQKXX+Ds y7beHSZCqYKKgL5yWi9Eot69Ug1j6royIPyFnfekbf16bQf1wdKu4v6Lz1X47a+kncd6 ME+bP2USdRmDTQqQVgNjIwFifob/gJd+twNBqpuzA+mizLFfh70F27+pS0QHjqKBatoV IzbvL3SKWRPbftCIGFgOlSBvviVBCzLkby0ybNDZYRs0CLjwb4zYL3wctefZbc2wL4xq DDPw== X-Gm-Message-State: AJaThX5ccRYNl7UBxhgLra59VZ9Az5UuD7hyruCrXi/iIZ2CJjXGKbq9 YDLsZFtH9g0CVmjW3MeEguQ= X-Received: by 10.55.100.149 with SMTP id y143mr50675092qkb.252.1511631066026; Sat, 25 Nov 2017 09:31:06 -0800 (PST) Received: from ?IPv6:2601:647:4580:b719:ad53:e4f2:a49d:b5cf? ([2601:647:4580:b719:ad53:e4f2:a49d:b5cf]) by smtp.gmail.com with ESMTPSA id z126sm9712136qka.70.2017.11.25.09.31.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 25 Nov 2017 09:31:05 -0800 (PST) From: Nadav Amit Message-Id: <372BBE7D-1397-4EFB-BB60-0638710F11DB@gmail.com> Content-Type: multipart/signed; boundary="Apple-Mail=_180F44C5-8A2E-46EE-9C01-57D6FF334752"; protocol="application/pgp-signature"; micalg=pgp-sha512 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH v2 2/2] x86: disable IRQs before changing CR4 Date: Sat, 25 Nov 2017 09:31:03 -0800 In-Reply-To: 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?= To: Thomas Gleixner References: <20171125032907.2241-1-namit@vmware.com> <20171125032907.2241-3-namit@vmware.com> <803D7D69-1F01-4CB8-A966-A040F302D1C0@gmail.com> 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 --Apple-Mail=_180F44C5-8A2E-46EE-9C01-57D6FF334752 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Thomas Gleixner wrote: > On Sat, 25 Nov 2017, Nadav Amit wrote: >> Thomas Gleixner wrote: >>=20 >>> 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); >>=20 >> 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. >=20 > I fixed that up already as I wanted to have it done, see the tip-bot = mail > in your inbox. Thanks, your changes made it much better. At some point it might be = better to make the MTRR code to use these interfaces too instead of meddling = with CR4 directly. Anyhow, that is a different story. Regards, Nadav --Apple-Mail=_180F44C5-8A2E-46EE-9C01-57D6FF334752 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE0YCJM4pMIpzxUdmOK4dOkxJsY0AFAloZqNcACgkQK4dOkxJs Y0DECA/9HpNVG0WiXDmY6+VbesNpXYxkGE9kMFyVWXLrbYacykTLj7sw4LFTsbat z07w73tmswu4RmbSD8fxFW5CDOPu+dOJpWPD3EtvbyQi4y2DY9GS3DVnFTYOwplP A5zUckn2Ve01doC/n1Oazy4/pOGBbaq1zifT6PFsXdCpK7R7Cm2mQ2oqysNEpdZB GDwYsqIKSBNqP4Kwz4Qn2AFwSEOVWzLrOxML8CVeR602Yzb8RmwfPvoUA2yvmFFk z2MscnTcCPyFfxq79kD3NKM+4Mnn9TM2jorPpqksAqybeNcDUWluSd5chQdh1FPV rP/vqWGAeePy0Gnifpy8Dk82cKgfIKxlWiWE2HUp/VLGdDe6MRlxtBGWGu/jBRxL DK0SetskIj/mSraLLEd1Dgx6QugGF47to3kFRrx0rxQ03tbFZczgj5BatFK3aWAG TRzcGSe2Q5EnN98KVDng7kD6soWwuxF3J0CBwkIm9N3vdTPrjr8s4x58Xlpyz8i9 WPTPqb0a0R5VhUVNtZkFfqg15/YXDyF0xzDSxvbz69naHlv8/4KYvlHg7lLnQTrI ifLz98s0nAo1VfwiZnRaI4STaHF4Edl5tyDC4vnYGlIZGQS21Fe+rCd+Amg+MMNU j9XDjXmd2YjG0rNf/6EnyB8RN837K73uPjfEA4SbeIWpZY4jnMY= =g7W6 -----END PGP SIGNATURE----- --Apple-Mail=_180F44C5-8A2E-46EE-9C01-57D6FF334752-- From 1585059764283489646@xxx Sat Nov 25 17:26:27 +0000 2017 X-GM-THRID: 1585008173950843474 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread