Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1951901rdh; Sat, 28 Oct 2023 14:27:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHDFVP2LdWH4PzTeiObKPd03zYRqk/NyGnY9f0/jrGkb1LBYA6RSDdctJSYOBddHRyY7XH7 X-Received: by 2002:a05:6e02:152a:b0:357:46e3:58be with SMTP id i10-20020a056e02152a00b0035746e358bemr8817120ilu.1.1698528446268; Sat, 28 Oct 2023 14:27:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698528446; cv=none; d=google.com; s=arc-20160816; b=FjQ0DWt3GyJ6znmdB9q/Z83vb1XaG052Sp+Xr+jw5T4wDSapV7blckkyEsDX9ve27G fI3ujmt9QbI8CFSPwQCR5DpPx1sMniQDFN9Ut3ypYKL4LBDCutvpLAmAGtiTkWFKLqOM +29l3heCOHrBwb2tJJCSuK6HNGXC32JvNbgl5PB+y54Zyoq2lqJHuFNie4VJUgU61JJQ M1dvucnzL3UZ5rBdqDiztTpWXh/6UsYKKo8vLcZS928MCK48fSapJtQJBzFNvUmKxXnv 2CjpHUCV0MwgfgLwnSNj9pHa53JJyO5sEECTOtya7PCaWrasCVy6vTLECgcE+0Xd0XTI z2Qw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=+3EhqydIk8cWL76gCn5A4FQeZ+oe6v5e7gK0rC5kDqw=; fh=BW7qVY89mXG5KeqOWeTstRIGCO882l030ianZ+WLfQA=; b=Yd0xSIswmSEQ+Rkv9kBwI5akjRqcy0IQsPEKEs/C99cJ+SKlw2M32fPzfsLMKQbV8f r3aiyMLbWX75XEBbD+f3iDy6VU4uyzOSTQxvEMl5bPfjl1l7qxZCDS6vq7d6STW08j/7 OlLen/NDnJFUEF0bXMlPlIRhK/hNxVofsVugq5q9csniKLkNodk5LE0aTlB/JmruwqB8 eAjvHwJo+U6dBEgAgqELnSdG0PFbQdPuSv0l8IOQuAXGbADEZz6Kq0x97HKgfFKBsXi6 0RDX9W4mz640wR/VVPSZ96wRbpON8txhd7nk9MniGcpfysII/GlSRKnx7ilgPu2eBECy 3OmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=P7WiuQcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id ky16-20020a170902f99000b001c9ce2b6b97si2941062plb.198.2023.10.28.14.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Oct 2023 14:27:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=P7WiuQcT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id AC9F98088A9E; Sat, 28 Oct 2023 14:26:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229450AbjJ1V0d (ORCPT + 99 others); Sat, 28 Oct 2023 17:26:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjJ1V0c (ORCPT ); Sat, 28 Oct 2023 17:26:32 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C45FCCA; Sat, 28 Oct 2023 14:26:29 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1cacf449c1aso6174665ad.0; Sat, 28 Oct 2023 14:26:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698528389; x=1699133189; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=+3EhqydIk8cWL76gCn5A4FQeZ+oe6v5e7gK0rC5kDqw=; b=P7WiuQcTvNtX2Jtb6KzV5ytOZiqRH6EHOR4x5+8hEi9To9ZbTJExEjfAuOD2zdUsKX SbRa3/26tPOg+yZpJcmsszy3Arz86EiCTzn81yhZ8nMHyPjwufyJeBsPI5AKupjsXoh3 T/Yos47NnHZT/Ovv/Ms9iTZEpOtmP+zUM8viWQUpy+B9nFxlBnJx4jsuh3v7eg43lUiq 2wXID7miutg6T4JcSS1aVsp3Dnmfm+FzJUHZ09Lcn8HIifqlNWy0BGMWCb6aFnjK0446 NFl2OvAdGPI55Ge5pPaRkAOBZz3NoP1r+47ppKcO300yjzCTsa7bEaVNAJnT9NTIQBfL tsRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698528389; x=1699133189; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+3EhqydIk8cWL76gCn5A4FQeZ+oe6v5e7gK0rC5kDqw=; b=ofzmEPDQdEljpot6L3CEf9XzpFfU84ppHcJN/gI9p5c8dZndecTRF7L+PhBF+xtkU6 /FkcjM8WBxwH4OuHerApl+852BoH5D06/arcRCUJX2SvaegL5cWWXUHpNYJ9jqVpWyjb jewLQ0FRGzkaWPF7pKfa47+zL/Y6x3r5h06rYGC5Zoiy/GB9awVqCvwm1GOh1utaI3FY PpWiEak0+XH0CFwUe/QXhbH4jGFSHOPe8/XukBPzMAaIWFHTS+OKWMq96+7QcPGxuF8O uvKam009DCl1Mh27OGKNyzn3LRW3x/pyzxNJtP/JIRySvrM97aLH1YsY6/T8XEkgkb5w BjHQ== X-Gm-Message-State: AOJu0Yx4sqcT/hF9uIsMnh37MzeP+yWPjn1nzoM8djIhd+vvC5ULtjuo 7IxIJEsqIKnOIJ4vuqY59imgzMs457ex2mTt X-Received: by 2002:a17:902:f213:b0:1c4:1cd3:8062 with SMTP id m19-20020a170902f21300b001c41cd38062mr6495445plc.2.1698528389175; Sat, 28 Oct 2023 14:26:29 -0700 (PDT) Received: from [192.168.0.152] ([103.75.161.209]) by smtp.gmail.com with ESMTPSA id 17-20020a170902c21100b001bbb8d5166bsm3607338pll.123.2023.10.28.14.26.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 28 Oct 2023 14:26:28 -0700 (PDT) Message-ID: <19cec6f0-e176-4bcc-95a0-9d6eb0261ed1@gmail.com> Date: Sun, 29 Oct 2023 02:56:17 +0530 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] Fixing warning cast removes address space '__iomem' of expression Content-Language: en-US To: "Michael Kelley (LINUX)" , KY Srinivasan , Haiyang Zhang , "wei.liu@kernel.org" , Dexuan Cui , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "hpa@zytor.com" , Nischala Yelchuri Cc: "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-kernel-mentees@lists.linuxfoundation.org" References: <20231024112832.737832-1-singhabhinav9051571833@gmail.com> From: Abhinav Singh In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Sat, 28 Oct 2023 14:26:39 -0700 (PDT) On 10/29/23 01:40, Michael Kelley (LINUX) wrote: > From: Abhinav Singh Sent: Tuesday, October 24, 2023 4:29 AM >> > > Subject lines usually have a prefix to indicate the area of the kernel > the patch is for. We're not always super consistent with the prefixes, > but you can look at the commit log for a file to see what is > typically used. In this case, the prefix is usually "x86/hyperv:" > >> >> This patch fixes sparse complaining about the removal of __iomem address >> space when casting the return value of this function ioremap_cache(...) >> from `void __ioremap*` to `void*`. > > Should avoid wording like "this patch" in commit messages. See > the commit message guidelines in the "Describe your changes" > section of Documentation/process/submitting-patches.rst. A > better approach is to just state the problem: "Sparse complains > about the removal .....". Then describe the fix. Also avoid > pronouns like "I" or "you". > >> >> I think there are two way of fixing it, first one is changing the >> datatype of variable `ghcb_va` from `void*` to `void __iomem*` . >> Second way of fixing it is using the memremap(...) which is >> done in this patch. >> >> Signed-off-by: Abhinav Singh >> --- >> arch/x86/hyperv/hv_init.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c >> index 21556ad87f4b..c14161add274 100644 >> --- a/arch/x86/hyperv/hv_init.c >> +++ b/arch/x86/hyperv/hv_init.c >> @@ -70,7 +70,7 @@ static int hyperv_init_ghcb(void) >> >> /* Mask out vTOM bit. ioremap_cache() maps decrypted */ > > This comment mentions ioremap_cache(). Since you are changing > to use memremap() instead, the comment should be updated to > match. > >> ghcb_gpa &= ~ms_hyperv.shared_gpa_boundary; >> - ghcb_va = (void *)ioremap_cache(ghcb_gpa, HV_HYP_PAGE_SIZE); >> + ghcb_va = memremap(ghcb_gpa, HV_HYP_PAGE_SIZE, MEMREMAP_WB); > > As noted in the comment, ioremap_cache() provides a mapping that > accesses the memory as decrypted. To be equivalent, the call to > memremap() should include the MEMREMAP_DEC flag so that it > also is assured of producing a decrypted mapping. > > Also, corresponding to the current ioremap_cache() call here, > there's an iounmap() call in hv_cpu_die(). To maintain proper > pairing, that iounmap() call should be changed to memunmap(). > > It turns out there are other occurrences of this same pattern in > Hyper-V specific code in the Linux kernel. See hv_synic_enable_regs(), > for example.Did "sparse" flag the same problem in those > occurrences? The particular warning msg for this case is like this "warning: cast removes address space '__iomem' of expression". I only saw these warning one time inside the arch/x86/ directory. >It turns out that Nischala Yelchuri at Microsoft is > concurrently working on fixing this occurrence as well as the > others we know about in Hyper-V specific code. So should I continue or not with this patch? > > Michael > >> >> -- >> 2.39.2 > Thanks for taking out the time for reviewing this and giving the suggestions. Thank You, Abhinav Singh