Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp344712rwl; Wed, 5 Apr 2023 01:12:19 -0700 (PDT) X-Google-Smtp-Source: AKy350ZorDSxOS8Rz+oszGTX5CUtxb+7BPCcHvkSZM8TSiDTwxlgpW85q8UOuCI65yKeibhTg4xN X-Received: by 2002:a05:6402:524e:b0:500:3fd0:25a8 with SMTP id t14-20020a056402524e00b005003fd025a8mr2023337edd.0.1680682339788; Wed, 05 Apr 2023 01:12:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680682339; cv=none; d=google.com; s=arc-20160816; b=wYyYDqUfz25YQshW8ycpS0VRvy+vSX4FAVf7o3euLzw5KbNm1JlVd3eQIL49GmwKP4 OGJrRCkfbq14fEp6NhgM2VYHsZTQiDk+fAShZyuTyBnZijcB3pR75qtHZrqIIcj8TeTY 6dxxvEwCVtWPDD+qyVNES8cZ5TMh898xw/+hmD7CWSFzsFLlcv+7wbUkNcAw4kHpzl8D 04AUmDlLyk43zAKdheD5Ar+8i9BW+CCGUOLtqsrmQrLRNjA8PtQlm/U0RRhA70aJ9N/s Nk8TMMTdhm1c4aFRNVylQFKrgDVZkkicw0YzfrAbfPdAtsrBhl3nv7ZvvXPm7Jz0BUDd Q6rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-filter; bh=dOEo2EG+hg+F81Lh9lwEURZ0dL7IZCs7WplCBPaibvo=; b=Xm0HzUIYG2DbiN4e4tASWj2Q5dkKDNi+AHNa5rW5nqeMuRQpvTW1XE/6+BAUrLmbU4 R/t5Uv1s74x6Aydt/sRo3LOKFNToyVQezfnXAiT19Xs8PTClUSL6drI3EujCmTuWrC7E AU4rxV9SgXgCP0n8qq3fuI4/aRuyjYMpMySHerxgBuGv/WCtA8CLMURVaQE10MGB6RFR T5OrJD/CKex/LpTGDUhNdxm01xCCztlMiLsCu+sgMFdcV7ldLLV9ODjY1/NtSSDUcT2I da55HUzb/lLMrBeKokfd7mn7zrwW8XRT+3jvaWL0ikXYuDO6xnemcWPm16UI58fQeNkE d7xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=YC8cjMJ2; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020aa7d1d0000000b00502a69a95dcsi3315265edp.449.2023.04.05.01.11.52; Wed, 05 Apr 2023 01:12:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@linux.microsoft.com header.s=default header.b=YC8cjMJ2; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237437AbjDEILs (ORCPT + 99 others); Wed, 5 Apr 2023 04:11:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237485AbjDEILc (ORCPT ); Wed, 5 Apr 2023 04:11:32 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1DC2149D8; Wed, 5 Apr 2023 01:11:14 -0700 (PDT) Received: from [192.168.2.41] (77-166-152-30.fixed.kpn.net [77.166.152.30]) by linux.microsoft.com (Postfix) with ESMTPSA id EDD69210DECB; Wed, 5 Apr 2023 01:10:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com EDD69210DECB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1680682261; bh=dOEo2EG+hg+F81Lh9lwEURZ0dL7IZCs7WplCBPaibvo=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=YC8cjMJ20KxMNhpu8rYiufuNP1UOoAx+dj565ZmzCfHdtTygT+Tx/FCmslVgL76R4 /uTKCk2TSXlGpvDPp/mb36P1ZniAUsgYM5srfr+ZsKiQ0I7Mf7hMuiLZ8uuQ1F6M8q bcxqRa5cWCqV/eThGBPjjg96SP7QR9wsD2CVeGH8= Message-ID: <35f6b321-1668-2b62-cb47-3f3760be2e1d@linux.microsoft.com> Date: Wed, 5 Apr 2023 10:10:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH v3 0/8] Support ACPI PSP on Hyper-V To: Thomas Gleixner , Borislav Petkov Cc: linux-kernel@vger.kernel.org, Brijesh Singh , Tom Lendacky , "Kalra, Ashish" , linux-crypto@vger.kernel.org, "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Ingo Molnar , Dave Hansen , x86@kernel.org References: <20230320191956.1354602-1-jpiotrowski@linux.microsoft.com> <20230322154655.GDZBsi75f6LnQStxSp@fat_crate.local> <1d25221c-eaab-0f97-83aa-8b4fbe3a53ed@linux.microsoft.com> <20230322181541.GEZBtFzRAMcH9BAzUe@fat_crate.local> <20230323152342.GFZBxu/m3u6aFUDY/7@fat_crate.local> <105d019c-2249-5dfd-e032-95944ea6dc8c@linux.microsoft.com> <20230323163450.GGZBx/qpnclFnMaf7e@fat_crate.local> <20230402154425.GCZCmi2eiKYO2yYhNs@fat_crate.local> <877cutsczn.ffs@tglx> Content-Language: en-US From: Jeremi Piotrowski In-Reply-To: <877cutsczn.ffs@tglx> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-19.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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-crypto@vger.kernel.org On 4/3/2023 8:20 AM, Thomas Gleixner wrote: > On Sun, Apr 02 2023 at 17:44, Borislav Petkov wrote: >> On Fri, Mar 24, 2023 at 06:10:09PM +0100, Jeremi Piotrowski wrote: >>> Since the AMD PSP is a privileged device, there is a desire to not have to trust the >>> ACPI stack, >> >> And yet you do: >> >> + err = acpi_parse_aspt(&res[0], &pdata); >> + if (err) >> + return err; >> >> You don't trust the ACPI stack, and yet you're parsing an ACPI table?!?! >> You have to make up your mind here. I gave you background on why Microsoft system designers like to use the ASPT on *physical hardware* in our datacenters. It is because it allows them to setup a highly privileged system component through an isolated ACPI table, without needing to depend on the *rest of the ACPI stack* (other ACPI tables and/or the ACPI interpreter). The same reason they use IVRS for AMD IOMMU. I thought it might be good to write this down, as this shows that the ASPT is a hardware interface that has *some* value. I don't think further discussion on this point helps us make forward progress. We're trying to adhere to a specification for a physical device when modeling that same device in a virtual environment. Yes, this requires parsing an ACPI table. >> >> Btw, you still haven't answered my question about doing: >> >> devm_request_irq(dev, 9, ..) >> >> where 9 is the default ACPI interrupt. >> >> You can have some silly table tell you what to map or you can simply map >> IRQ 9 and be done with it. In this second case you can *really* not >> trust ACPI because you know which IRQ it is. > So I originally thought I answered when i said "because we're trying to not deviate from the hardware specification for the PSP". Interrupt configuration is part of that specification. But when I think about what you're suggesting, I can interpret it two ways: 1. Configure the PSP to raise the vector corresponding to ACPI IRQ 9. This might work and would look similar to the first version I posted. I'd fetch 'struct irq_cfg' for acpi_sci_irq, write the corresponding APIC-ID/vector into the PSP, enable PSP interrupt generation and then probe the "ccp" driver so that it can call "devm_request_irq(9)". I assume this would also require registering an irq affinity notifier, much like drivers/iommu/amd/init.c did before commit d1adcfbb520c. 2. Deviate from the hardware specification. From reading acpi code (not at all an expert on this), that "9" does not look like a static value to me, so it requires either: a) passing a GSI number in an ACPI table b) defining it as being the same interrupt as the SCI, which comes from the FADT table. c) using the GPE mechanism of the ACPI SCI interrupt. So I'd need to define a third way for the PSP to interrupt the OS, one that would only be supported on Hyper-V. Work with our hypervisor and/or virtual firmware teams to make sure that the PSP model supports generating the interrupt in this way. Work with the Windows team to make Windows support it (the same virtual hardware model/virtual firmware is used regardless of the OS). I have no objection to doing "1." if it works. I don't see it as a big win over using an irq_domain. I don't think "2." is a reasonable thing to ask. We do regularly make suggestions to hypervisor/firmware teams on how to make things better supported in Linux without requiring hacks. But modelling a piece of hardware in a custom way to avoid following hardware specs is questionable. I also think that soon, when other people deploy more SEV-SNP hardware in their datacenters, they will also want to rely on the ASPT for the reasons listed at the top of the email, so we'll be adding support for it anyway. Which way do you suggest we go Boris? I'm not attached to the code at all but I am attached to adhering to hardware specifications. I can try to do "1." or stick with the irq_domain approach that i posted. Thanks, Jeremi