Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp839428imm; Fri, 12 Oct 2018 07:31:45 -0700 (PDT) X-Google-Smtp-Source: ACcGV61qccfF5NuiPe/3It9WQrtDmUBuCmYjAwllsH6u4CqRDrKaG8wDDzvhIk8GJiYRbHFRYAh2 X-Received: by 2002:a62:6dc3:: with SMTP id i186-v6mr6430894pfc.218.1539354705635; Fri, 12 Oct 2018 07:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539354705; cv=none; d=google.com; s=arc-20160816; b=QsSd/YLKBUidebZF00143NBqlakAcHqzXegsJH13ST5N+IzXiMcHK56sVyqJttFLED jYzML+bOaMg91KDvOsO2SeTYO+DnqEp78t08RSG3uxFxE4MUI5+HMA8wHpawPNa5c/4G AsJHRjON+6PhQjbWB+aDvIr29xJPl4v05SfOp14/y73zKWzb4lbFPFBfcbzi7W/NRw6J 0DHgkwPM+5foh2ZugoqerEchvZVDDuT2qyDJF8+tahtXMrzA+D9IdtOxrsSfAnt5f6tw 5IJg1HHhU3769uLTjeQAdlXfJ9bT8D/O+XfWtz9vcanroCDpE+MWPIwFX2D9IqXcY1l0 a2Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-filter; bh=G4tH1GqziO+Rr7+Yg7PiBlPCTidDEFw+RJcOk3Sc3ic=; b=dzE/G0wXrpqb+nUccvzu+JwlG6KC3VR0mFeqfTUJc83aymeCVzC0MWMtN7SIuqMbYE TpGXsilmCeY12lFPSSTNg2He/S6MpspYWa/iKcEThPTeaqtFTNefS1mrDjEQyR6B+Lrk rVU0LgIHD4+TnSOy1fP1vtFgP18qafvLg/EpVhHi5dly4xr91mLN3qgc08PAWZI89VNj BdcaHOQhRFBTwNfGJQ3InEhlhxXQkmg0FXetV1hg6rPabRtU+kq/RwzZpnIwd5VZTzSx ZY0/zlQwLIR8xucuBIbLMwx1kB3gaKKcAhp5DyK+7X/MWr51gkoVQjxP1fv6tvZnjYJa dgMg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c184-v6si1373575pfg.215.2018.10.12.07.31.30; Fri, 12 Oct 2018 07:31:45 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728832AbeJLWCH (ORCPT + 99 others); Fri, 12 Oct 2018 18:02:07 -0400 Received: from smtp.dei.uc.pt ([193.137.203.253]:49786 "EHLO smtp.dei.uc.pt" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728354AbeJLWCH (ORCPT ); Fri, 12 Oct 2018 18:02:07 -0400 Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (user=sneves mech=PLAIN bits=0) by smtp.dei.uc.pt (8.15.2/8.15.2) with ESMTPSA id w9CESceM010961 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Fri, 12 Oct 2018 15:28:43 +0100 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.dei.uc.pt w9CESceM010961 Received: by mail-ed1-f54.google.com with SMTP id c26-v6so11679617edt.3 for ; Fri, 12 Oct 2018 07:28:43 -0700 (PDT) X-Gm-Message-State: ABuFfoi92grEMV30vIlI8fj247zUGo1fiKJ3XTWmnwTMOAMnbXfkULg4 hqW00gHmsAAl/h+eLT6cS0/njvffsDtl37Hphe4= X-Received: by 2002:a50:9583:: with SMTP id w3-v6mr9437897eda.33.1539354517878; Fri, 12 Oct 2018 07:28:37 -0700 (PDT) MIME-Version: 1.0 References: <20181011185458.10186-1-kristen@linux.intel.com> In-Reply-To: From: Samuel Neves Date: Fri, 12 Oct 2018 15:28:01 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] x86: entry: flush the cache if syscall error To: Jann Horn Cc: Andy Lutomirski , kristen@linux.intel.com, Kernel Hardening , Thomas Gleixner , Ingo Molnar , bp@alien8.de, "H. Peter Anvin" , "the arch/x86 maintainers" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-FCTUC-DEI-SIC-MailScanner-Information: Please contact helpdesk@dei.uc.pt for more information X-FCTUC-DEI-SIC-MailScanner-ID: w9CESceM010961 X-FCTUC-DEI-SIC-MailScanner: Found to be clean X-FCTUC-DEI-SIC-MailScanner-SpamCheck: not spam, SpamAssassin (cached, score=-60.1, required 3.252, autolearn=not spam, ALL_TRUSTED -10.00, BAYES_00 -0.10, L_SMTP_AUTH -50.00) X-FCTUC-DEI-SIC-MailScanner-From: sneves@dei.uc.pt X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 12, 2018 at 2:26 PM Jann Horn wrote: > > On Fri, Oct 12, 2018 at 11:41 AM Samuel Neves wrote: > > > > On Thu, Oct 11, 2018 at 8:25 PM Andy Lutomirski wrote: > > > What exactly is this trying to protect against? And how many cycles > > > should we expect L1D_FLUSH to take? > > > > As far as I could measure, I got 1660 cycles per wrmsr 0x10b, 0x1 on a > > Skylake chip, and 1220 cycles on a Skylake-SP. > > Is that with L1D mostly empty, with L1D mostly full with clean lines, > or with L1D full of dirty lines that need to be written back? Mostly empty, as this is flushing repeatedly without bothering to refill L1d with anything. On Skylake the (averaged) uops breakdown is something like port 0: 255 port 1: 143 port 2: 176 port 3: 177 port 4: 524 port 5: 273 port 6: 616 port 7: 182 The number of port 4 dispatches is very close to the number of cache lines, suggesting one write per line (with respective 176+177+182 port {2, 3, 7} address generations). Furthermore, I suspect it also clears L1i cache. For 2^20 wrmsr executions, we have around 2^20 frontend_retired_l1i_miss events, but a negligible amount of frontend_retired_l2_miss ones.