Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp708950ybi; Fri, 31 May 2019 07:49:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyvP6STWj/9N3JO2j4lcFS0V0KKs8agVLIUY6R7cvTKvi7YG3u9bicpSSdLUaSZCuJRd3hT X-Received: by 2002:a63:5c1a:: with SMTP id q26mr10095389pgb.260.1559314196590; Fri, 31 May 2019 07:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559314196; cv=none; d=google.com; s=arc-20160816; b=X+zMT+8DhCWTtFsxUedOtdHepRPALEbV7KNGxsMeTLqIUvYBD75pWu8UPY0l0ondVk gHXeUCq+TJZXIhxiCaliauJuFkAhYrS8YnCMq4zCUD6LWb50MQBNp3gOxLlUBAD1upYS S0F9vJ45K32a3zJ2V0uoowuoMg+DwywrprAKDytdwlyr2qA4UugVCLv00VzKa0rP1la7 XxeeWyXndXIuVKU11Tta82/Vx2oRjP9Ho0Df5c8EiPzbFWPXymXau/uFjfjatellc4D6 hD6YtuvokzZT1/CEn+wxDIh/9nVdN0QyIdcWnLu+CeLB249yXN/Hthg/TNmmqtJTmQpV 0cnw== 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; bh=+oLbiZHvRS3KJUUhvyJO8fvkgdbxNQmutC3j5WyUYO0=; b=Ql3myBpuQ7Noo/KZK48ekWu7wTmgjX5aPtsIjYvYFq7ctRmnLeGEzIhDo42zz/X0ri s0rYmhKaV7/Tm/J0+t71mkdBq0IeqmwlD35JOInjLfWqTXsvH0YZPt7kIjYR/pKh4wy8 mSjvZnyMLVrklwahAhFksMwk6HIe4WZhD+8WupjzsM57D36B3HC64SRK/R5JSeiwAUKr 3j+hqdAXpOdFwWnJTmZJCylw95hEnB7F2qP1N6b7nWahhHRDyx6R+LoDqx6Gw86qHDCA eRJ2WJCB/4M4Ezl0fXKMVIRMO5Cu64K/aQ/ookK3CPm6D/REHV5TDIHVf5GOtST6ROH3 7+Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="ow1qafi/"; 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 f12si6380102pgi.484.2019.05.31.07.49.38; Fri, 31 May 2019 07:49:56 -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; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="ow1qafi/"; 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 S1726809AbfEaOqr (ORCPT + 99 others); Fri, 31 May 2019 10:46:47 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:36799 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726515AbfEaOqr (ORCPT ); Fri, 31 May 2019 10:46:47 -0400 Received: by mail-pl1-f195.google.com with SMTP id d21so4119635plr.3 for ; Fri, 31 May 2019 07:46:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=+oLbiZHvRS3KJUUhvyJO8fvkgdbxNQmutC3j5WyUYO0=; b=ow1qafi/yDoy8hGQWMfwkPT9Czm8xE8VCHegc942/JfVLkxWoeAZTJ/r/KQszB4j79 lRAOGX/CGV0r7ulIhOSHWJ6PcOYCv+8EwodLCDnazKRw87eZoPFce7ssEr2Pohve5f1p IiDGn6AWl6hxoL2jnoCm4qWaGJHEdkqnwZ0yZ+bjWFwxXZJbpkhJv+qDssNFzcEvkTzB Bx8VVtmQhhuzpVLbCh4YGFTCq16QL2z+bfqzP4QzbkOPXDDLyrfMEb6s6tDf1nl7Td6c Ou1To2DqffD5NV1BPsd1JpPLWaa70yEf/j1Uy+nQe7SqxZ9mklc5axPnkhAsewU4h9MT Rkvg== 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=+oLbiZHvRS3KJUUhvyJO8fvkgdbxNQmutC3j5WyUYO0=; b=LovITmzhGfl8rOw8thcLgs739gqwyc2IuKlMo/dwRyZmwxlmZaHjlzJ/zIoLFgJPaK bQbylkIf1Je6HDsQ53IkwEf7ynt28gQ6PRi5vWU6UIborxVPGzW6D4yGNeZyUxyeTWQh /fsILJOuFRJbjUeR4k1PuymXStQoEKoMgNXCj0sjbUhgxBHJzKoWMxCDJbJ5/QV8t+RC D7KL890H+scpA67P2TE0qd+H/hjQpffiIU4LK4joOsorHS8/xAJbuLVFZd0KRKku3ren U95oPJJTbQG7eRJpNRejd1mAGHdgK9ONAHHinvzjt2PdqY0YDAHq6aIz1ORPruHBLl36 nmkg== X-Gm-Message-State: APjAAAWldpHExd8xOB26nj5EuW3JxAS/3QR0s1psvN+TwzG9Jbv224cD wHPM4bNPbihrbnS2jkFau4OH7w== X-Received: by 2002:a17:902:7c15:: with SMTP id x21mr9799142pll.311.1559314006938; Fri, 31 May 2019 07:46:46 -0700 (PDT) Received: from ?IPv6:2601:646:c200:1ef2:40a6:bfd8:6bf:bfbe? ([2601:646:c200:1ef2:40a6:bfd8:6bf:bfbe]) by smtp.gmail.com with ESMTPSA id l141sm13355299pfd.24.2019.05.31.07.46.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 07:46:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v4] x86/power: Fix 'nosmt' vs. hibernation triple fault during resume From: Andy Lutomirski X-Mailer: iPhone Mail (16E227) In-Reply-To: Date: Fri, 31 May 2019 07:46:44 -0700 Cc: Andy Lutomirski , "Rafael J. Wysocki" , Josh Poimboeuf , "Rafael J. Wysocki" , Thomas Gleixner , the arch/x86 maintainers , Pavel Machek , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Peter Zijlstra , Linux PM , Linux Kernel Mailing List Content-Transfer-Encoding: quoted-printable Message-Id: References: <20190531051456.fzkvn62qlkf6wqra@treble> <5564116.e9OFvgDRbB@kreacher> To: Jiri Kosina Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On May 31, 2019, at 7:31 AM, Jiri Kosina wrote: >=20 >> On Fri, 31 May 2019, Andy Lutomirski wrote: >>=20 >> 2. Put the CPU all the way to sleep by sending it an INIT IPI. >>=20 >> Version 2 seems very simple and robust. Is there a reason we can't do >> it? We obviously don't want to do it for normal offline because it >> might be a high-power state, but a cpu in the wait-for-SIPI state is >> not going to exit that state all by itself. >>=20 >> The patch to implement #2 should be short and sweet as long as we are >> careful to only put genuine APs to sleep like this. The only downside >> I can see is that an new kernel resuming and old kernel that was >> booted with nosmt is going to waste power, but I don't think that's a >> showstopper. >=20 > Well, if *that* is not an issue, than the original 3-liner that just=20 > forces them to 'hlt' [1] would be good enough as well. >=20 >=20 Seems okay to me as long as we=E2=80=99re confident we won=E2=80=99t get a s= purious interrupt. In general, I don=E2=80=99t think we=E2=80=99re ever suppose to rely on mwai= t *staying* asleep. As I understand it, mwait can wake up whenever it wants= , and the only real guarantee we have is that the CPU makes some effort to s= tay asleep until an interrupt is received or the monitor address is poked. As a trivial example, if we are in a VM and we get scheduled out at any poin= t between MONITOR and the eventual intentional wakeup, we=E2=80=99re toast. S= ame if we get an SMI due to bad luck or due to a thermal event happening sho= rtly after pushing the power button to resume from hibernate. For that matter, what actually happens if we get an SMI while halted? Does R= SM go directly to sleep or does it re-fetch the HLT? It seems to me that we should just avoid the scenario where we have IP point= ed to a bogus address and we just cross our fingers and hope the CPU doesn=E2= =80=99t do anything. I think that, as a short term fix, we should use HLT and, as a long term fix= , we should either keep the CPU state fully valid or we should hard-offline t= he CPU using documented mechanisms, e.g. the WAIT-for-SIPI state.=