Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7207C4363C for ; Sun, 4 Oct 2020 07:49:37 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6397B206B5 for ; Sun, 4 Oct 2020 07:49:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="GOmwn9li" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6397B206B5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.2698.7717 (Exim 4.92) (envelope-from ) id 1kOylc-0002rx-BT; Sun, 04 Oct 2020 07:49:12 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 2698.7717; Sun, 04 Oct 2020 07:49:12 +0000 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOylc-0002rq-8W; Sun, 04 Oct 2020 07:49:12 +0000 Received: by outflank-mailman (input) for mailman id 2698; Sun, 04 Oct 2020 07:49:11 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOylb-0002rl-Na for xen-devel@lists.xenproject.org; Sun, 04 Oct 2020 07:49:11 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 02868a1c-4f92-4777-8d21-18e81fd90842; Sun, 04 Oct 2020 07:49:10 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E294CAC4F; Sun, 4 Oct 2020 07:49:09 +0000 (UTC) Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1kOylb-0002rl-Na for xen-devel@lists.xenproject.org; Sun, 04 Oct 2020 07:49:11 +0000 X-Inumbo-ID: 02868a1c-4f92-4777-8d21-18e81fd90842 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 02868a1c-4f92-4777-8d21-18e81fd90842; Sun, 04 Oct 2020 07:49:10 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1601797750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bZKPBlisJQ0e/BqVkzd4Dke9AIEZYsp8PmP08KzYou0=; b=GOmwn9liJ8WnuwauzIrLFKSNHVoq3Vt0374amLcWvVE6d5e+SmPge7jnezRd3oVK6NNnle 8EYSWo+X8bDMCKQjUil42LzTUADJOOsqDVJ9C2PvwtLOefU+whmNKAEf7OwUYvH0reUb0U 455E/jrfFO7hA+va9ty1v/wD0hG3Fhc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id E294CAC4F; Sun, 4 Oct 2020 07:49:09 +0000 (UTC) Subject: Re: S3 resume crash in memguard_guard_stack (stable-4.14) To: =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= , Andrew Cooper References: <20201003135723.GO3962@mail-itl> Cc: xen-devel From: Jan Beulich Message-ID: <74e9a18e-4c50-5341-8f3b-e23a5382e515@suse.com> Date: Sun, 4 Oct 2020 09:49:09 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20201003135723.GO3962@mail-itl> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 03.10.2020 15:57, Marek Marczykowski-Górecki wrote: > With this, I get a crash on S3 resume: > > (XEN) Preparing system for ACPI S3 state. > (XEN) Disabling non-boot CPUs ... > (XEN) Entering ACPI S3 state. > (XEN) [VT-D]Passed iommu=no-igfx option. Disabling IGD VT-d engine. > (XEN) mce_intel.c:773: MCA Capability: firstbank 0, extended MCE MSR 0, BCAST, CMCI > (XEN) CPU0 CMCI LVT vector (0xf1) already installed > (XEN) Finishing wakeup from ACPI S3 state. > (XEN) Enabling non-boot CPUs ... > (XEN) ----[ Xen-4.14.1-pre x86_64 debug=y Not tainted ]---- > (XEN) CPU: 0 > (XEN) RIP: e008:[] memguard_guard_stack+0x7/0x1a5 > (XEN) RFLAGS: 0000000000010286 CONTEXT: hypervisor > (XEN) rax: ffff830250ca03f8 rbx: 0000000000000001 rcx: ffff830250cb10b0 > (XEN) rdx: 0000003210739000 rsi: 0000000000000001 rdi: ffff830250ca0000 > (XEN) rbp: ffff830049a6fd70 rsp: ffff830049a6fd40 r8: 0000000000000001 > (XEN) r9: 0000000000000000 r10: 0000000000000001 r11: 0000000000000002 > (XEN) r12: 0000000000010000 r13: 0000000000000000 r14: 0000000000000001 > (XEN) r15: ffff82d040598440 cr0: 000000008005003b cr4: 00000000003526e0 > (XEN) cr3: 0000000049a5d000 cr2: ffff830250ca03f8 > (XEN) fsb: 0000000000000000 gsb: 0000000000000000 gss: 0000000000000000 > (XEN) ds: 0000 es: 0000 fs: 0000 gs: 0000 ss: 0000 cs: e008 > (XEN) Xen code around (memguard_guard_stack+0x7/0x1a5): > (XEN) c3 48 8d 87 f8 03 00 00 <48> 89 87 f8 03 00 00 48 8d 87 f8 07 00 00 48 89 > (XEN) Xen stack trace from rsp=ffff830049a6fd40: > (XEN) ffff82d040321c2e ffff82d040461b68 ffff82d040461b60 ffff82d040461240 > (XEN) 0000000000000001 0000000000000000 ffff830049a6fdb8 ffff82d040221f9c > (XEN) ffff830049a6fde0 0000000000000001 0000000000000000 00000000ffffffef > (XEN) ffff830049a6fe08 0000000000000001 ffff830250b66000 ffff830049a6fdd0 > (XEN) ffff82d0402036cf 0000000000000001 ffff830049a6fdf8 ffff82d040203a4d > (XEN) 0000000000000000 0000000000000001 0000000000000010 ffff830049a6fe28 > (XEN) ffff82d040203d00 ffff830049a6fef8 0000000000000000 0000000000000003 > (XEN) 0000000000000200 ffff830049a6fe58 ffff82d040270c9a ffff830250139f70 > (XEN) ffff830250b45000 0000000000000000 0000000000000000 ffff830049a6fe78 > (XEN) ffff82d040207064 ffff830250b451b8 ffff82d0405781b0 ffff830049a6fe90 > (XEN) ffff82d04022b7bb ffff82d0405781a0 ffff830049a6fec0 ffff82d04022ba9c > (XEN) 0000000000000000 ffff82d0405781b0 ffff82d04057ed00 ffff82d040598440 > (XEN) ffff830049a6fef0 ffff82d0402f33e3 ffff830252b0e000 ffff830250b45000 > (XEN) ffff830252b0f000 0000000000000000 ffff830049a6fdc8 ffff88818ce029e0 > (XEN) ffffc900026b7f08 0000000000000003 0000000000000000 0000000000003403 > (XEN) ffffffff8277a5a8 0000000000000246 0000000000000003 0000000000003403 > (XEN) 0000000000003403 0000000000000000 ffffffff810020ea 0000000000003403 > (XEN) 0000000000000010 deadbeefdeadf00d 0000010000000000 ffffffff810020ea > (XEN) 000000000000e033 0000000000000246 ffffc900026b7cb8 000000000000e02b > (XEN) 0000000000000000 0000000000000000 0000000000000000 0000000000000000 > (XEN) Xen call trace: > (XEN) [] R memguard_guard_stack+0x7/0x1a5 > (XEN) [] S smpboot.c#cpu_smpboot_callback+0xe5/0x6d5 > (XEN) [] F notifier_call_chain+0x6b/0x96 > (XEN) [] F cpu.c#cpu_notifier_call_chain+0x1b/0x33 > (XEN) [] F cpu_up+0x5f/0xd5 > (XEN) [] F enable_nonboot_cpus+0xea/0x1fb > (XEN) [] F power.c#enter_state_helper+0x152/0x606 > (XEN) [] F domain.c#continue_hypercall_tasklet_handler+0x4c/0xb9 > (XEN) [] F tasklet.c#do_tasklet_work+0x76/0xa9 > (XEN) [] F do_tasklet+0x58/0x8a > (XEN) [] F domain.c#idle_loop+0x40/0x96 > (XEN) > (XEN) Pagetable walk from ffff830250ca03f8: > (XEN) L4[0x106] = 8000000049a5b063 ffffffffffffffff > (XEN) L3[0x009] = 0000000250cae063 ffffffffffffffff > (XEN) L2[0x086] = 0000000250cad063 ffffffffffffffff > (XEN) L1[0x0a0] = 8000000250ca0161 ffffffffffffffff Now this one's pretty obvious: The call to memguard_unguard_stack() during bringing down the APs is conditional (in cpu_smpboot_free()) and hence memguard_guard_stack() may (at present) not assume the stack is writable (by ordinary writes, i.e. write_sss_token()). I guess we may want something like if ( stack_base[cpu] == NULL ) { stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, memflags); if ( stack_base[cpu] == NULL ) goto out; } else if ( IS_ENABLED(CONFIG_XEN_SHSTK) ) memguard_unguard_stack(stack_base[cpu]); in cpu_smpboot_alloc(). But of course the question is whether the conditions here and there wouldn't better become cpu_has_xen_shstk, since right now the breakage (afaict) needlessly extends to systems that aren't CET-capable. Jan