Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp297252ybi; Fri, 31 May 2019 01:28:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqy9PM0GmRgtiZJx0bv+Y8N4JNPSgTUnS9MHV+jETOd8Yy/CgKFIpsv5be+Q8sDqj8ZbJcz9 X-Received: by 2002:a63:f513:: with SMTP id w19mr3665564pgh.367.1559291282149; Fri, 31 May 2019 01:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559291282; cv=none; d=google.com; s=arc-20160816; b=cBFjP+g5tfjMHEjuKNa0g+uWcnTatWVhXphqb2O9/cJI48heF06XSMUAPIaCX4DTqe T6uzjlXmxRiArnvDshilstriD6sXDItajShBl2Owwhd51VZxngntWhBMxpxsxHPg7Ebh rX0EqaxCBrFTdvuhpxbsG+ogxPo2a5tnaDObN5MO7LoMhwxJtyno5wLb2FccC0lTDsoi CgOco+f4WPVYuORc02ReID0t3dpqykXMZIOEV2Q8sVzDBTgd09E6wrZfUWiequAft237 WSDOA41jG8mloKJBx5VNVkEizGd7mY/4eokGQx5V/O8kaEkgcgc5rnbQXlQorm738HBc QQXg== 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:date:subject:cc:to:from; bh=dZLODz2JwwjbWxnoOKXwG4xTlAmxcQMtvm4egioFVJA=; b=MgQbO+09gFbkjgllHCk15O/EaNJqqKtC2u0xofjQwoFT/z8tkRm7U/xNxEzUCK1ipQ mluU4IEAd+dzzc56MfOLElHil9tQZ1bQJb6y5KYMqgsrIWZ+WwdANm4suYYTwNbdoHIo xa5D+A/pvAt6BtCbmBPzZwLdRXRmpElYKdj7VrUqLZUrmLQFzPG1n9Gv3xiYr6M0Lc0D 8w4Wwdfsz5gfByMTdiTYmZwDPJTZu9mB500rBV+bi8RaSxrJyK8xt23YxlOaaaG2L19M T99VtGwp5bw9c896kvhb89Nk5Bs1gdppQLX9TmcQBqH6Msa3CapgO/qSrVtVP9e2NVNg YAqw== 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 d35si542571pla.349.2019.05.31.01.27.46; Fri, 31 May 2019 01:28:02 -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 S1726917AbfEaI0l (ORCPT + 99 others); Fri, 31 May 2019 04:26:41 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:44708 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726240AbfEaI0k (ORCPT ); Fri, 31 May 2019 04:26:40 -0400 Received: from 79.184.255.225.ipv4.supernova.orange.pl (79.184.255.225) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.213) id 839ca75bcd552a6f; Fri, 31 May 2019 10:26:38 +0200 From: "Rafael J. Wysocki" To: Josh Poimboeuf , Jiri Kosina Cc: "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 , Andy Lutomirski Subject: Re: [PATCH v4] x86/power: Fix 'nosmt' vs. hibernation triple fault during resume Date: Fri, 31 May 2019 10:26:37 +0200 Message-ID: <1639292.WxYr0VA4et@kreacher> In-Reply-To: <20190531051456.fzkvn62qlkf6wqra@treble> References: <20190531051456.fzkvn62qlkf6wqra@treble> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Friday, May 31, 2019 7:14:56 AM CEST Josh Poimboeuf wrote: > On Fri, May 31, 2019 at 01:42:02AM +0200, Jiri Kosina wrote: > > On Thu, 30 May 2019, Josh Poimboeuf wrote: > > > > > > > Reviewed-by: Thomas Gleixner > > > > > > > > Yes, it is, thanks! > > > > > > I still think changing monitor/mwait to use a fixmap address would be a > > > much cleaner way to fix this. I can try to work up a patch tomorrow. > > > > I disagree with that from the backwards compatibility point of view. > > > > I personally am quite frequently using differnet combinations of > > resumer/resumee kernels, and I've never been biten by it so far. I'd guess > > I am not the only one. > > Fixmap sort of breaks that invariant. > > Right now there is no backwards compatibility because nosmt resume is > already broken. > > For "future" backwards compatibility we could just define a hard-coded > reserved fixmap page address, adjacent to the vsyscall reserved address. > > Something like this (not yet tested)? Maybe we could also remove the > resume_play_dead() hack? Yes, we can IMO, but in a separate patch, please. > diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h > index 9da8cccdf3fb..1c328624162c 100644 > --- a/arch/x86/include/asm/fixmap.h > +++ b/arch/x86/include/asm/fixmap.h > @@ -80,6 +80,7 @@ enum fixed_addresses { > #ifdef CONFIG_X86_VSYSCALL_EMULATION > VSYSCALL_PAGE = (FIXADDR_TOP - VSYSCALL_ADDR) >> PAGE_SHIFT, > #endif > + FIX_MWAIT = (FIXADDR_TOP - VSYSCALL_ADDR - 1) >> PAGE_SHIFT, > #endif > FIX_DBGP_BASE, > FIX_EARLYCON_MEM_BASE, > diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c > index 73e69aaaa117..9804fbe25d03 100644 > --- a/arch/x86/kernel/smpboot.c > +++ b/arch/x86/kernel/smpboot.c > @@ -108,6 +108,8 @@ int __read_mostly __max_smt_threads = 1; > /* Flag to indicate if a complete sched domain rebuild is required */ > bool x86_topology_update; > > +static char __mwait_page[PAGE_SIZE]; > + > int arch_update_cpu_topology(void) > { > int retval = x86_topology_update; > @@ -1319,6 +1321,8 @@ void __init native_smp_prepare_cpus(unsigned int max_cpus) > smp_quirk_init_udelay(); > > speculative_store_bypass_ht_init(); > + > + set_fixmap(FIX_MWAIT, __pa_symbol(&__mwait_page)); > } > > void arch_enable_nonboot_cpus_begin(void) > @@ -1631,11 +1635,12 @@ static inline void mwait_play_dead(void) > } > > /* > - * This should be a memory location in a cache line which is > - * unlikely to be touched by other processors. The actual > - * content is immaterial as it is not actually modified in any way. > + * This memory location is never actually written to. It's mapped at a > + * reserved fixmap address to ensure the monitored address remains > + * valid across a hibernation resume operation. Otherwise a triple > + * fault can occur. > */ > - mwait_ptr = ¤t_thread_info()->flags; > + mwait_ptr = (void *)fix_to_virt(FIX_MWAIT); > > wbinvd(); > > Jiri, any chance to test this?