Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1898939ybn; Thu, 26 Sep 2019 04:01:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7kmJfufRmXWiXcQAl3F82HwHCa4wp23WwSl6a/0y0CUemYnl/wZoC/igLrbmPoZTL1wOz X-Received: by 2002:aa7:c759:: with SMTP id c25mr2815297eds.15.1569495682122; Thu, 26 Sep 2019 04:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569495682; cv=none; d=google.com; s=arc-20160816; b=WqEkkYSJwtKKfPN6aAWECbEK1ROXHdP4wFRarEHTnwfM3h4zbjAktCi9PUross8IKu qLwG7mgbzr7Athuil8VsYvcfsx6vmuqvQHD9r5Yv0iS3kwtQEB7nkx8iTqqMJt2XlTk9 MCWoYDs0yGTbzNJSwqYhLEEeOYNqNe4A7MgFG4NdLnU1E1mC3/dMuNYgjSQnfh6E/dBm xvJREUthZUJ2EaR3PUxdw5H0y8FZWanDwPtq8/jx3lWbRNbr2cxoAZUqTB62zD9LocJJ tbpy160ikH5ILQfKJzS2TtxFx27rsGvPyc+ZDV9wo9VTQ10bsSPJx/O72/iw1GFc3tbR rMow== 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=Riw/2Ux9OsHBDm8paJcZzsJiBRoPakD2IyewC8/qlH0=; b=WU4lklp6QH8QDwHyj67ilOAnhQNr3OuT832FUAJA/g8aLQlvawbPgKTebW6kamuH1C plHOrQbjGTbd6mXVHaJJfzRAXUsCw9Gh2odh8M/rvUDBjriqtEuELrEHdjV3C3aQ6ZLH NoUpv4ACjQDd+Z4mztVrRa3/vPsGbOunqA90nZUiMvTXdaycdApXn5wQP6EqJQ6LEeju /gC25yCvYsR2g4skDdfngfK/EJSvCydS8EIV7b4/cB3YEiPfqOSHPqeYJTcWLdpltCQs I3cLNlrHi8ZCps6V6iKCn6W8+wXF/D0+cU4dTGy8BkW/hNHl0WsC8ob9eu2QmOLmQmMZ PqyQ== 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 t18si830321ejr.205.2019.09.26.04.00.58; Thu, 26 Sep 2019 04:01:22 -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 S1725843AbfIZKoU (ORCPT + 99 others); Thu, 26 Sep 2019 06:44:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32952 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbfIZKoU (ORCPT ); Thu, 26 Sep 2019 06:44:20 -0400 Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (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 E7C2AC056808 for ; Thu, 26 Sep 2019 10:44:19 +0000 (UTC) Received: by mail-wm1-f71.google.com with SMTP id m16so854987wmg.8 for ; Thu, 26 Sep 2019 03:44:19 -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=Riw/2Ux9OsHBDm8paJcZzsJiBRoPakD2IyewC8/qlH0=; b=Mco0TBV9DX/7E10CumnZrhfv8bS76zwzIi/K8vk6uaNLhCcGnkDcoK1ckoCFqZSFiD n6edbWmkC+vGpNAi+6YHRt/E8p3ZBFy6aeyXS8jK09JGFSwDL799AFqtqB6owqkpwR0S xX+twSYZRYMCfW0Oufg7DjeT3XpEKQe3epAtpiEdJY1T2q4lk4DaPQfHM0GjpsLSh01/ hi4SSZ51bWkOYGKxjacnpBHIoys4ywUuBgz8aYD83jj18zoP02iHd07WcJUujxw/P0oO V8boV7TFGt1CfI7aNpg68+0TQygmEMNLEkL4npry+t/Cc22YvPfqrkPJxdstxOaryozF w+aQ== X-Gm-Message-State: APjAAAWfQrNwiPAz6aHH0gK8v0uwSrXdBeK6NSwag4UJnyVJRzEAaXzZ ivzTc8+PutxVN53vrKBTGIa/fvidobeDL6A8rYcDH2LZHT+UBj7VKCdPGkV0JkBek//CoxePCHf sj65nUdj8xt4PzJg6MVFAQUlK X-Received: by 2002:adf:f8cf:: with SMTP id f15mr2319309wrq.292.1569494658664; Thu, 26 Sep 2019 03:44:18 -0700 (PDT) X-Received: by 2002:adf:f8cf:: with SMTP id f15mr2319287wrq.292.1569494658461; Thu, 26 Sep 2019 03:44:18 -0700 (PDT) Received: from vitty.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id q19sm3835597wra.89.2019.09.26.03.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2019 03:44:17 -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: <1567723581-29088-2-git-send-email-decui@microsoft.com> References: <1567723581-29088-1-git-send-email-decui@microsoft.com> <1567723581-29088-2-git-send-email-decui@microsoft.com> Date: Thu, 26 Sep 2019 12:44:16 +0200 Message-ID: <87ef0372wv.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: > This is needed for hibernation, e.g. when we resume the old kernel, we need > to disable the "current" kernel's hypercall page and then resume the old > kernel's. > > Signed-off-by: Dexuan Cui > Reviewed-by: Michael Kelley > --- > arch/x86/hyperv/hv_init.c | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c > index 866dfb3..037b0f3 100644 > --- a/arch/x86/hyperv/hv_init.c > +++ b/arch/x86/hyperv/hv_init.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > > void *hv_hypercall_pg; > @@ -223,6 +224,34 @@ static int __init hv_pci_init(void) > return 1; > } > > +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