Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp753919qtx; Thu, 17 Nov 2022 07:38:38 -0800 (PST) X-Google-Smtp-Source: AA0mqf5vqGD8IxDQk0baWbzwX2YPJGVpTTHWwvkOrn8W4TocfhHZ9LI0OIWo5I2Ram/9TEHfWe2t X-Received: by 2002:a17:906:b46:b0:7ad:a030:4816 with SMTP id v6-20020a1709060b4600b007ada0304816mr2531805ejg.765.1668699517964; Thu, 17 Nov 2022 07:38:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668699517; cv=none; d=google.com; s=arc-20160816; b=e1O3EBUNGeEMwlxT5PToZxvKAfc49/IDPc0OCBWzQQkaptDGRPjuH/IPBKORylcL06 4hkpfI9CLkwewTcfLAuTr9/PQ9Z14FG2He+Po5AdW1T+bMWkb+wbH6yvkncsYL3uhrDf tU3sYwEiwCASbyUDHilM+HZC9LI6vurhS7jcXbjvCgWIvBUxXV6jCYg0Oh723EKtzNFr km5nBivcc2bhZMuQWj5wJe4H/HbirWnVzB3vx5nSEW/EbaZk6BX6nfBFVyhPOGnz10Dm P2ruozbtYDTva0MVbLW1kPMH2BHOamH3rnHu986n4hUKl05nAeFYgjauvbPzjpKIwvNC ORZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=QqLoz4WimLaZOBWkpHa++cXKf6tUCOzTWtaNskWwH9g=; b=Ip33ooNGGN0OQNgdLGN9VwpL3WoMGVQeU+vLjCwYoM9WAWKPzqroh1c0bzaIyJM3CD E9tis82eLKp+qIB5b1mfSL3F3efcpL/0S42GRed9ecpO9Q6qyGc+CoHpKXLwUSIiT4gS dJV3shhlSer25KEAj7N6w1Dg68wEmtFtR6K7Cy6VgNy45xt13SlSFqLsLXuA9D4B9hRx Tu7e2zzwzyLI6C9Ml+RurzwUgJuduK9GHNfh3DiwOQFn/nhVpMJ9YOrSH5bPzS1uUn92 D0/VX90+AZpfnaqfCa8bt7XIVJZ+REpZCfz1NuXwYaxjC+r1tfD+cKDoPyvLUMgui0Vk cQUw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a17090646c900b007a7d22b9e0bsi717207ejs.133.2022.11.17.07.38.15; Thu, 17 Nov 2022 07:38:37 -0800 (PST) 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; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240733AbiKQPVl (ORCPT + 92 others); Thu, 17 Nov 2022 10:21:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240648AbiKQPUw (ORCPT ); Thu, 17 Nov 2022 10:20:52 -0500 Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A927990C; Thu, 17 Nov 2022 07:17:10 -0800 (PST) Received: by mail-wm1-f43.google.com with SMTP id t4so1594391wmj.5; Thu, 17 Nov 2022 07:17:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QqLoz4WimLaZOBWkpHa++cXKf6tUCOzTWtaNskWwH9g=; b=i5g+VeGE+d7rY1AeqrFIQtYVRpDlQhNScnfUz+PDNhG3clVb7g2B2vcrN73dqwPQqA M0zOLmJl+fdkq1LdCNBOsMNpcMVinn8dlLuzO5H1EFgCAq4VDkj09cOmmbICGsTMAfBm zyWLuxjkz/BmFxlI6zJAj2EgCLXcvkFkvNX0ko9rW+kNjTenRsERcWGMrndsLLjI66bA 7f9tbSRRy0vMhjPbBQOO9q5ZExbMTrFlr6J7TKfmWrrIOQppOIrGbB0A7m+0OD1whZUv EseLWuIQLYQb3R7me5WRFEnpRRmDPICxkRoLvUO6ymYeHy/SsdESpwELG7K79TlqO83f Q09Q== X-Gm-Message-State: ANoB5pkpfC2yNj4fYuZAVJI2X9VQVlCgdbK2OwoMVbvRN32pU0Feokff BYqj3+44oEVIr9zOLvtjlH4= X-Received: by 2002:a05:600c:220b:b0:3cf:f747:71f with SMTP id z11-20020a05600c220b00b003cff747071fmr3969071wml.147.1668698206322; Thu, 17 Nov 2022 07:16:46 -0800 (PST) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id g17-20020a05600c4ed100b003c701c12a17sm6914886wmq.12.2022.11.17.07.16.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Nov 2022 07:16:45 -0800 (PST) Date: Thu, 17 Nov 2022 15:16:38 +0000 From: Wei Liu To: Michael Kelley Cc: hpa@zytor.com, kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, luto@kernel.org, peterz@infradead.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, lpieralisi@kernel.org, robh@kernel.org, kw@linux.com, bhelgaas@google.com, arnd@arndb.de, hch@infradead.org, m.szyprowski@samsung.com, robin.murphy@arm.com, thomas.lendacky@amd.com, brijesh.singh@amd.com, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, Tianyu.Lan@microsoft.com, kirill.shutemov@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com, ak@linux.intel.com, isaku.yamahata@intel.com, dan.j.williams@intel.com, jane.chu@oracle.com, seanjc@google.com, tony.luck@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org, iommu@lists.linux.dev Subject: Re: [Patch v3 13/14] PCI: hv: Add hypercalls to read/write MMIO space Message-ID: References: <1668624097-14884-1-git-send-email-mikelley@microsoft.com> <1668624097-14884-14-git-send-email-mikelley@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1668624097-14884-14-git-send-email-mikelley@microsoft.com> X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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 On Wed, Nov 16, 2022 at 10:41:36AM -0800, Michael Kelley wrote: [...] > > +static void hv_pci_read_mmio(struct device *dev, phys_addr_t gpa, int size, u32 *val) > +{ > + struct hv_mmio_read_input *in; > + struct hv_mmio_read_output *out; > + u64 ret; > + > + /* > + * Must be called with interrupts disabled so it is safe > + * to use the per-cpu input argument page. Use it for > + * both input and output. > + */ Perhaps adding something along this line? WARN_ON(!irqs_disabled()); I can fold this in if you agree. > + in = *this_cpu_ptr(hyperv_pcpu_input_arg); > + out = *this_cpu_ptr(hyperv_pcpu_input_arg) + sizeof(*in); > + in->gpa = gpa; > + in->size = size; > + > + ret = hv_do_hypercall(HVCALL_MMIO_READ, in, out); > + if (hv_result_success(ret)) { > + switch (size) { > + case 1: > + *val = *(u8 *)(out->data); > + break; > + case 2: > + *val = *(u16 *)(out->data); > + break; > + default: > + *val = *(u32 *)(out->data); > + break; > + } > + } else > + dev_err(dev, "MMIO read hypercall error %llx addr %llx size %d\n", > + ret, gpa, size); > +} > + > +static void hv_pci_write_mmio(struct device *dev, phys_addr_t gpa, int size, u32 val) > +{ > + struct hv_mmio_write_input *in; > + u64 ret; > + > + /* > + * Must be called with interrupts disabled so it is safe > + * to use the per-cpu input argument memory. > + */ Ditto. Thanks, Wei.