Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3017265iog; Mon, 20 Jun 2022 09:24:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tzruodVxtaEIc6zvSIt+LjI8cGCpOg2KAPRU/9VbI7p2TlxLSv11dRurQzbwnr+pWDTi6w X-Received: by 2002:a05:6402:398:b0:435:6df7:b7e4 with SMTP id o24-20020a056402039800b004356df7b7e4mr15815249edv.306.1655742287274; Mon, 20 Jun 2022 09:24:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655742287; cv=none; d=google.com; s=arc-20160816; b=SKDnwVczZd6bAdppcd+rqILHuRovjJrBuQpxzoLQg3VYI0IYN95ypqaKxcnR84E/nR X7y3U61TGOaYEMzLuNZbYVlgKUWJrPMXWh71EKeRCio6ZKZ+NYW7EilcmqptRWQ2PHzU /lg11c04KrGEze0HB6Xn2EyFz65j8Q+fUKbXtVmPapYYyobI1QR0bGuUH/+UgL2gCoxp JvqEoQYMW4XjimVRvw3OJ9WuyDdTpLAM7y17tWSlTeBXkmyfZnfdbqy9qVufi4IFR1wT mdMLzpJo/vyyOcy1Et1QOZPKlrhXnN0eGs8r9Dsv+82bqWQKcYcUaOcouET6y5BeZu2w CR8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=UF07x+KnC24YwAp8Zs4wTUOe9n56U36o0sDtsdMKcd8=; b=L7jyptM2E17L7r/DjlRWOd6ND3ZIckuJ/XCOA202edCU2LPfp4wm7Tgbik2Vrdykg7 9vN1IXOaNeBfBJ29R7opzqZZTQyeTJx/sYCQAX6P3qKSJ3hxf7gr25fMj8j4qL2AorMe I7+tvoNy4i0TZo6ZNsnOsmWFdQ2M2DmhXtW4ozbUy7CJiUKzsS/L+1zum3zgSRDxbt6Y rDpj9iV7ejnGWFB9ROWC/zpQEwMzrXTnk/0sAWC0fK9VJfkbS0ksHfRIfynkO0n6jowe 8CtmqweVhlG2l1syzz/8T950KXZxqR71XVMVtRsDIMNNUPXmd0Ag5IyX0uQfb2mQbm+u cV0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=Y8eqlHQk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kz1-20020a17090777c100b00711bd5bbe4bsi116170ejc.585.2022.06.20.09.24.21; Mon, 20 Jun 2022 09:24:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=Y8eqlHQk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238812AbiFTPoQ (ORCPT + 99 others); Mon, 20 Jun 2022 11:44:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236110AbiFTPoN (ORCPT ); Mon, 20 Jun 2022 11:44:13 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B68FE1AD94 for ; Mon, 20 Jun 2022 08:44:11 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id f16so9185389pjj.1 for ; Mon, 20 Jun 2022 08:44:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=UF07x+KnC24YwAp8Zs4wTUOe9n56U36o0sDtsdMKcd8=; b=Y8eqlHQkFI6Q7/UGjenXvlQi5VFjn2bOO+EB4M6bkbVpQp5Feutj2lG2yJAlO2tva5 6mWHpvRhz7WQuOaqNRspQjyloBLJMiZJz6zlk0SRN4MuqlZ+EvZ1ih4AIlwGId0CvBrs 7QOkdjtsuKU4gVduY0wlBbwACw1l52voPohchtPGrrnvQYLH83OFXOc2Eglg+siP7woh Hmk8o2gAKYI6PG1fxoPAxf1MdmTU/EljkqwlhNfMpRWmeSkRsy9hvn+EwqywbNYOlhp+ ukq7JDLv53AL+1NxEZ3rSWztWILGbj6q2nTOVxtTdVr4LyMYUI9DFCfGby5WMdqTFxhd Bbsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=UF07x+KnC24YwAp8Zs4wTUOe9n56U36o0sDtsdMKcd8=; b=kWHFRzFz7UlO9S9b+nAsidZVAR6PGi+PZK3SZB/J/zaxoYIKCtzFUUJjsbPCBJsg6g URRhcXvOh0Q/OXyZPEpfcRqt1DOM6V0rh3S0V2aG5mMxPTW/C/AsM8tFnP8BuwSN74Qm fkvoDzjQHB7JEpowYulwsG54BM9H7gqDlEpTA6thkZmI1U6Xk3dqupP6n5pO9/qnV6mf BEYsZX8PHNlJj2a3npXMuJiFB9fpFJUm6H/Hna5SnzW1UDRf59QXHlG3MUvxC1BIBkUk Ub/cnZVnLKAhpS8Uj7099x29qEnIpEioDN1QMlZWIfBQmSJIGxyzHKF0frfT/f3idil4 ulsg== X-Gm-Message-State: AJIora93z82Muk+UAcwH90/YAm6ZkM8eb4lUv6cMOfF1di7Yp7oaXfJ2 Ea6RbVSL7Y6huwT64xac/o7UX36cj2IH7o2fD2hstg== X-Received: by 2002:a17:90b:3e8a:b0:1ec:c09d:7963 with SMTP id rj10-20020a17090b3e8a00b001ecc09d7963mr667756pjb.199.1655739850930; Mon, 20 Jun 2022 08:44:10 -0700 (PDT) MIME-Version: 1.0 References: <20220609110337.1238762-1-jaz@semihalf.com> <20220609110337.1238762-2-jaz@semihalf.com> <2201fe5f-5bd8-baaf-aad5-eaaea2f1e20e@amd.com> In-Reply-To: <2201fe5f-5bd8-baaf-aad5-eaaea2f1e20e@amd.com> From: Grzegorz Jaszczyk Date: Mon, 20 Jun 2022 17:43:59 +0200 Message-ID: Subject: Re: [PATCH 1/2] x86: notify hypervisor about guest entering s2idle state To: "Limonciello, Mario" , Sean Christopherson Cc: linux-kernel@vger.kernel.org, Dmytro Maluka , Zide Chen , Peter Fang , Tomasz Nowicki , Paolo Bonzini , Jonathan Corbet , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "Rafael J. Wysocki" , Len Brown , Pavel Machek , Ashish Kalra , Hans de Goede , Sachi King , Arnaldo Carvalho de Melo , David Dunn , Wei Wang , Nicholas Piggin , "open list:KERNEL VIRTUAL MACHINE (KVM)" , "open list:DOCUMENTATION" , "open list:ACPI" , "open list:HIBERNATION (aka Software Suspend, aka swsusp)" , Dominik Behr , Dmitry Torokhov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org czw., 16 cze 2022 o 18:58 Limonciello, Mario napisa=C5=82(a): > > On 6/16/2022 11:48, Sean Christopherson wrote: > > On Wed, Jun 15, 2022, Grzegorz Jaszczyk wrote: > >> pt., 10 cze 2022 o 16:30 Sean Christopherson napis= a=C5=82(a): > >>> MMIO or PIO for the actual exit, there's nothing special about hyperc= alls. As for > >>> enumerating to the guest that it should do something, why not add a n= ew ACPI_LPS0_* > >>> function? E.g. something like > >>> > >>> static void s2idle_hypervisor_notify(void) > >>> { > >>> if (lps0_dsm_func_mask > 0) > >>> acpi_sleep_run_lps0_dsm(ACPI_LPS0_EXIT_HYPERVISOR_NO= TIFY > >>> lps0_dsm_func_mask, lps0_dsm= _guid); > >>> } > >> > >> Great, thank you for your suggestion! I will try this approach and > >> come back. Since this will be the main change in the next version, > >> will it be ok for you to add Suggested-by: Sean Christopherson > >> tag? > > > > If you want, but there's certainly no need to do so. But I assume you = or someone > > at Intel will need to get formal approval for adding another ACPI LPS0 = function? > > I.e. isn't there work to be done outside of the kernel before any patch= es can be > > merged? > > There are 3 different LPS0 GUIDs in use. An Intel one, an AMD (legacy) > one, and a Microsoft one. They all have their own specs, and so if this > was to be added I think all 3 need to be updated. Yes this will not be easy to achieve I think. > > As this is Linux specific hypervisor behavior, I don't know you would be > able to convince Microsoft to update theirs' either. > > How about using s2idle_devops? There is a prepare() call and a > restore() call that is set for each handler. The only consumer of this > ATM I'm aware of is the amd-pmc driver, but it's done like a > notification chain so that a bunch of drivers can hook in if they need to= . > > Then you can have this notification path and the associated ACPI device > it calls out to be it's own driver. Thank you for your suggestion, just to be sure that I've understand your idea correctly: 1) it will require to extend acpi_s2idle_dev_ops about something like hypervisor_notify() call, since existing prepare() is called from end of acpi_s2idle_prepare_late so it is too early as it was described in one of previous message (between acpi_s2idle_prepare_late and place where we use hypercall there are several places where the suspend could be canceled, otherwise we could probably try to trap on other acpi_sleep_run_lps0_dsm occurrence from acpi_s2idle_prepare_late). 2) using newly introduced acpi_s2idle_dev_ops hypervisor_notify() call will allow to register handler from Intel x86/intel/pmc/core.c driver and/or AMD x86/amd-pmc.c driver. Therefore we will need to get only Intel and/or AMD approval about extending the ACPI LPS0 _DSM method, correct? I wonder if this will be affordable so just re-thinking loudly if there is no other mechanism that could be suggested and used upstream so we could notify hypervisor/vmm about guest entering s2idle state? Especially that such _DSM function will be introduced only to trap on some fake MMIO/PIO access and will be useful only for guest ACPI tables? Thank you, Grzegorz