Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp3168169ybn; Fri, 27 Sep 2019 02:08:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwM415BUPpVhiojl8WoxxsRDxr6Y86qDdAdIUGpII9GZFuUva7t/hce61dcj0Rkiy769p92 X-Received: by 2002:a17:906:25ca:: with SMTP id n10mr6951753ejb.106.1569575314821; Fri, 27 Sep 2019 02:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569575314; cv=none; d=google.com; s=arc-20160816; b=bTh06OmmAyTiLAMMgyOR12yeZvUXjAybM1YBvfAg6oIsbPByNq0NMDcvX3iTQBip2O laU9ln3m16PYQOwspCSUA6G92v9TWiGiMeJnaVY8KJMJ5l0SbdGxmOXHwWtWOxB5Apoc SYAaEyRfMSKYt5N5+PBeay+7uYKKnELRrYWmr24JejO37Hp2DRqcaYNvctDxgrirU6az dL5yBUxLCH7YnG1kiamWGyYuTNRrL8Zu4RYIHn54nr/H9d0aS7xpACboCKXwultHZegb ZQFiXSkNV+UFxfHov/JtkUeUG1WX1nPDfNk5UHZrwcCRnvzIEPPn7pAETuoZxaBXf95u 3tjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=bbUXI7HnyvMO5i/vr47nNTN4Si9R/+ix2Rzt2/ZHUhs=; b=J0KzJLkBcZXAUbi+N1HdRTa7VNa3Z1M/9xoSZmbwbs8frci282D5rUypOWtILu7bmX Jvsxql+nKDFgRdoHi/HFka6hZS2ESHkskz3mJtEM3bQvrPjB8Z9P7BivlLThEtMJqJhV 3FRLdl0zAK/uSGtLtHTN7ZVJ4N8r92z5folrurP8yfZTlf8XvM95jZ+aNsipXrG6GsSv 8GqPFEhBdrgOnimUT3m7xwVvy6shdTqWfHZRaGRe533mfG+lVKjq30TYAqox55rLSlyJ 2ks7T8srf0YP7EmdIKv3h11I9HLSFAZTZJtxjRlTRBk36Ln4hR4nSdzSsRpivItARu3C wh1g== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si1131480eds.363.2019.09.27.02.08.08; Fri, 27 Sep 2019 02:08:34 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbfI0JF3 (ORCPT + 99 others); Fri, 27 Sep 2019 05:05:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56324 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726033AbfI0JF3 (ORCPT ); Fri, 27 Sep 2019 05:05:29 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2E4CB89AC5 for ; Fri, 27 Sep 2019 09:05:28 +0000 (UTC) Received: by mail-wm1-f69.google.com with SMTP id q9so2459690wmj.9 for ; Fri, 27 Sep 2019 02:05:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version; bh=bbUXI7HnyvMO5i/vr47nNTN4Si9R/+ix2Rzt2/ZHUhs=; b=GiJ/Iic7oneR2uDi4B0f6riRdwL3YGrEYl/YtvXDZ+2Y7lVGkzTXnPQx+80xG5xV/k a9ENkzKFP8ZZrdkbhkN3hJhR7erwQMFMCP8v5VWi0m+eKavSuFO4pD2xmOYdisrmB+G5 D25YSQPsWH0c03SLNrO9Mtc55NhMHkB52URMPGL1dN4Qb6+nCfqbHg31dd1W5tLWrZQP 6PMIP9uESJjxird+aXXW079oIrpyfDt23VlEpsszSf9RwpFwl/UtH6QrwLxf0n8tIXzF kB0CCJzxlboACxxGSPuiOALN8Tuwrqfi178+94q9uEcL62AsxAKoVV6BBijct0tTJxAV +79A== X-Gm-Message-State: APjAAAWtXcMGXd/PZkVZfq2DcePG+bnRQkrFPINEfx+kAllhg2dbHU/A enKljWsA+Hz5HvpP20gUIkBBB3bnmnhiXG1TFjh80t/bFjLCSkqsiDR+9tPAWp0Wg2ar22Z0yy+ +9nD7BT74REQQ+wZMNtgyyaIq X-Received: by 2002:adf:e692:: with SMTP id r18mr1981253wrm.339.1569575126802; Fri, 27 Sep 2019 02:05:26 -0700 (PDT) X-Received: by 2002:adf:e692:: with SMTP id r18mr1981220wrm.339.1569575126530; Fri, 27 Sep 2019 02:05:26 -0700 (PDT) Received: from vitty.brq.redhat.com ([95.82.135.182]) by smtp.gmail.com with ESMTPSA id w18sm5380136wmc.9.2019.09.27.02.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Sep 2019 02:05:25 -0700 (PDT) From: Vitaly Kuznetsov To: Dexuan Cui Cc: "linux-arch\@vger.kernel.org" , "arnd\@arndb.de" , "bp\@alien8.de" , "daniel.lezcano\@linaro.org" , Haiyang Zhang , "hpa\@zytor.com" , KY Srinivasan , "linux-hyperv\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" , "mingo\@redhat.com" , "sashal\@kernel.org" , Stephen Hemminger , "tglx\@linutronix.de" , "x86\@kernel.org" , Michael Kelley , Sasha Levin Subject: RE: [PATCH v5 1/3] x86/hyper-v: Suspend/resume the hypercall page for hibernation In-Reply-To: References: <1567723581-29088-1-git-send-email-decui@microsoft.com> <1567723581-29088-2-git-send-email-decui@microsoft.com> <87ef0372wv.fsf@vitty.brq.redhat.com> Date: Fri, 27 Sep 2019 11:05:24 +0200 Message-ID: <877e5u6re3.fsf@vitty.brq.redhat.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dexuan Cui writes: >> From: Vitaly Kuznetsov >> Sent: Thursday, September 26, 2019 3:44 AM >> > [...] >> > +static int hv_suspend(void) >> > +{ >> > + union hv_x64_msr_hypercall_contents hypercall_msr; >> > + >> > + /* Reset the hypercall page */ >> > + rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); >> > + hypercall_msr.enable = 0; >> > + wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64); >> > + >> >> (trying to think out loud, not sure there's a real issue): >> >> When PV IPIs (or PV TLB flush) are enabled we do the following checks: >> >> if (!hv_hypercall_pg) >> return false; >> >> or >> if (!hv_hypercall_pg) >> goto do_native; >> >> which will pass as we're not invalidating the pointer. Can we actually >> be sure that the kernel will never try to send an IPI/do TLB flush >> before we resume? >> >> Vitaly > > When hv_suspend() and hv_resume() are called by syscore_suspend() > and syscore_resume(), respectively, all the non-boot CPUs are disabled and > only CPU0 is active and interrupts are disabled, e.g. see > > hibernate() -> > hibernation_snapshot() -> > create_image() -> > suspend_disable_secondary_cpus() > local_irq_disable() > > syscore_suspend() > swsusp_arch_suspend > syscore_resume > > local_irq_enable > enable_nonboot_cpus > > > So, I'm pretty sure no IPI can happen between hv_suspend() and hv_resume(). > self-IPI is not supposed to happen either, since interrupts are disabled. > > IMO TLB flush should not be an issue either, unless the kernel changes page > tables between hv_suspend() and hv_resume(), which is not the case as I > checked the related code, but it looks in theory that might happen, say, in > the future, so if you insist we should save the variable "hv_hypercall_pg" > to a temporary variable and set the "hv_hypercall_pg" to NULL before we > disable the hypercall page Let's do it as a future proof so we can keep relying on !hv_hypercall_pg everywhere we need. No need to change this patch IMO, a follow-up would do. -- Vitaly