From patchwork Thu Jun 30 08:41:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 12901426 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6982C43334 for ; Thu, 30 Jun 2022 08:43:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6486F8E0003; Thu, 30 Jun 2022 04:43:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F61F6B0074; Thu, 30 Jun 2022 04:43:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BE498E0003; Thu, 30 Jun 2022 04:43:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3EC1D6B0073 for ; Thu, 30 Jun 2022 04:43:55 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1B88E357F9 for ; Thu, 30 Jun 2022 08:43:55 +0000 (UTC) X-FDA: 79634264430.02.FE122FA Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf23.hostedemail.com (Postfix) with ESMTP id C6F5B140042 for ; Thu, 30 Jun 2022 08:43:54 +0000 (UTC) Received: by mail-lj1-f173.google.com with SMTP id a11so22154889ljb.5 for ; Thu, 30 Jun 2022 01:43:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R+x4xUlXaoDhtuO4AscHrz+MJh/LM6gsUwNc9kO1v+E=; b=OSmDR7wary1m1qUfrlxL2I6Ug0MRO/qHr/34gExjesE+/q3nH9Z6LM9IpyxGURbS/e d94KEmX77fcR/Db51wz5FYadJVArANKXYKIR8/an06jAfRDQDaZuB7QeUY0gDXlWawbf HzNHH4ZHSNJoKH9iFSwcCJBBh1ZsRajJ1h4dK6KYPyOt+I59Tp3kwW11PmC5A4bWwypC 2p4PfnqcWgHbmHU705IUG3aMXH7wBmiHZCg+kqxVaoV5DS74iNEiwntKMhVj+CWdYL9p Ey+UZcYv5qV2AnVZiDvMy7zUE1hVyAHFhZdFJyPfHNjtwIhSUgeK9x5KWXVjWC30SiST kCPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R+x4xUlXaoDhtuO4AscHrz+MJh/LM6gsUwNc9kO1v+E=; b=Pwdadiat65r+TWNartldR53+EpKMZQFG+gch73InnlvRy0FDY/4fX2Ok41Epk3cTAY HxH2G4ESh6pNv3KI6H9hxEvQ+R7xjS5lq2SftXz32skF8N5y2uwGL/fkta+rUiO2EWk5 3Gv2G3BrjnTBu3N6S9A3Uf8hGcUjqwi3vpYfPy5mkgEFAoxr7dvgFbIYL5LIP173xjaA Pw/uO1C6+b/vDCe/+h+rT57l/ZYIelzAv6BZVgMFzxZxkgyKi67L7LILMOV6K00dSTle DJ9tlH09w56yzp/VUq/vOy89lKcGy5vckKshLpsOcl1+yuQGwZNe//+HC8VoCKaDn37h VyhA== X-Gm-Message-State: AJIora+rah5bmDtW79MG/bk6P9n0RADuEnH4V204Yz8UQ1alxH7E4It6 jUJG4H5JXPzjejp5tDkdB1Iczg== X-Google-Smtp-Source: AGRyM1ux2ROim9MMsELLAdIM+hGEz9MlFxZrA74q2h10NXMDFRi+J2wQIDeULLfRxLLAl0Px/GIr9Q== X-Received: by 2002:a05:651c:231f:b0:25a:66c3:c213 with SMTP id bi31-20020a05651c231f00b0025a66c3c213mr4221114ljb.288.1656578633145; Thu, 30 Jun 2022 01:43:53 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id o23-20020a05651205d700b0047f62762100sm2973023lfo.138.2022.06.30.01.43.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jun 2022 01:43:52 -0700 (PDT) From: Linus Walleij To: Andrew Morton Cc: linux-mm@kvack.org, Linus Walleij , Alexander Potapenko , Marco Elver , Dmitry Vyukov , kasan-dev@googlegroups.com Subject: [PATCH 3/5] mm: kfence: Pass a pointer to virt_to_page() Date: Thu, 30 Jun 2022 10:41:22 +0200 Message-Id: <20220630084124.691207-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220630084124.691207-1-linus.walleij@linaro.org> References: <20220630084124.691207-1-linus.walleij@linaro.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656578634; a=rsa-sha256; cv=none; b=j9Kd7KkJIgL/69tMVUJqHjl+7czPUGwVnHwVcV2YfnVP3/dSvyZEHrBWzm5kDLY/UrW8P2 +kcPO4QKUvl9wSLWuDqHJjNR06w3Xs8oulNBD54FA1F6pM674+SGlxct24Q+1CyDMW1b4c Q332buhZ3f8fqFaCvXqrNgr4QFxtDrg= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=OSmDR7wa; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf23.hostedemail.com: domain of linus.walleij@linaro.org designates 209.85.208.173 as permitted sender) smtp.mailfrom=linus.walleij@linaro.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656578634; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=R+x4xUlXaoDhtuO4AscHrz+MJh/LM6gsUwNc9kO1v+E=; b=jPR03CY178JpGrN7mczpogs+lG8WxEnV2Tk3l9sYAfjz3YPvsSX8HZQoT+TAu8+Sj2hcEq v4nar5kPGZGbQqc45XYwY+rzS1OhzCVWFeGPVR+8h5wbcLiNz+gK0skpAHF1Wkt/H20yY/ AXIW32NOAg2lCahamRlXJEkP/2DgpDs= X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C6F5B140042 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=linaro.org header.s=google header.b=OSmDR7wa; dmarc=pass (policy=none) header.from=linaro.org; spf=pass (imf23.hostedemail.com: domain of linus.walleij@linaro.org designates 209.85.208.173 as permitted sender) smtp.mailfrom=linus.walleij@linaro.org X-Rspam-User: X-Stat-Signature: 16591othjbckemmh46whjuju5w5mtcyt X-HE-Tag: 1656578634-104630 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Functions that work on a pointer to virtual memory such as virt_to_pfn() and users of that function such as virt_to_page() are supposed to pass a pointer to virtual memory, ideally a (void *) or other pointer. However since many architectures implement virt_to_pfn() as a macro, this function becomes polymorphic and accepts both a (unsigned long) and a (void *). If we instead implement a proper virt_to_pfn(void *addr) function the following happens (occurred on arch/arm): mm/kfence/core.c:558:30: warning: passing argument 1 of 'virt_to_pfn' makes pointer from integer without a cast [-Wint-conversion] In one case we can refer to __kfence_pool directly (and that is a proper (char *) pointer) and in the other call site we use an explicit cast. Cc: Andrew Morton Cc: Alexander Potapenko Cc: Marco Elver Cc: Dmitry Vyukov Cc: kasan-dev@googlegroups.com Cc: linux-mm@kvack.org Signed-off-by: Linus Walleij Reviewed-by: Marco Elver --- mm/kfence/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/kfence/core.c b/mm/kfence/core.c index 4e7cd4c8e687..153cde62ad72 100644 --- a/mm/kfence/core.c +++ b/mm/kfence/core.c @@ -543,7 +543,7 @@ static unsigned long kfence_init_pool(void) if (!arch_kfence_init_pool()) return addr; - pages = virt_to_page(addr); + pages = virt_to_page(__kfence_pool); /* * Set up object pages: they must have PG_slab set, to avoid freeing @@ -657,7 +657,7 @@ static bool kfence_init_pool_late(void) /* Same as above. */ free_size = KFENCE_POOL_SIZE - (addr - (unsigned long)__kfence_pool); #ifdef CONFIG_CONTIG_ALLOC - free_contig_range(page_to_pfn(virt_to_page(addr)), free_size / PAGE_SIZE); + free_contig_range(page_to_pfn(virt_to_page((void *)addr)), free_size / PAGE_SIZE); #else free_pages_exact((void *)addr, free_size); #endif