Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp256815pxj; Thu, 10 Jun 2021 21:23:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYBrV1L+bre2vYLOvj3WLasg4LLmzxD+EWiEwknwadlcpV9KZ4+9nEXPAJ4sMSq32IuSWS X-Received: by 2002:a17:906:6d97:: with SMTP id h23mr1644356ejt.467.1623385410714; Thu, 10 Jun 2021 21:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623385410; cv=none; d=google.com; s=arc-20160816; b=Nr8/95kwsN0VqQaHx/r/xLseWfY0un4tlbP6s2N/MhBPdkFhMUoqkptigfnhcOMCZN /HHoKM3S3gEmf6RpSNbuYeDey7fL0IICR4UhGWpmt5tf9YvYkkaFJVEVQfYtsRa4MK2s pr1/uIEmSJezFSoJ0c+BvL7UvBkUFNsfMUw+jiQMpGdX7dcVyKqtZ2uYqHUalRegrLqy JZEeLsGPCb+yC0K/bOctGk2O5Zkvoemixm+NXHavb4Cj9GLy+8/VOg7oPJQ8hW7CBQn8 oUerBg/stj85E+uMClhrHKwaJbtLYGYK3Yy4tSwkePlcfgK70sAxaT3dgXW3jyZ8cHr2 RGug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ZHLizz1mShpY2BBwDSwnXD5bJ90lY9tk/czQAYvJWmY=; b=OW5OVj5zRg0EEXQah/PLYBbpbN7EO2Rhq5/EPRk2SCiwkJj0Ghchpl+R8GrRSxusXz yohFPFebDfC9CzbXlEhg3baopAfFgXT04KZRkeY4Q1BB1C2Uzrvz0AKeF7vcdHnyLws5 vvEKvpBA6k6TaeHoKSvx4uYYhDXr0GPEmAO9RRWtDQawHnCLCtV9bBNljSzeeVKruzR8 uzeP3UZD8BvZ/ZXi3QIg2uMwQvQmfJLAvKS7BzbZTHQU42dcA5ASwNRbWgiel7f5aVhr da6t0L2RoAXJJGqu11tVZQ4zb3SLb5PxptxqZcVBUixupFBlWvS5m30fr6FggClMyybf 2gMQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di7si4135399ejc.71.2021.06.10.21.23.05; Thu, 10 Jun 2021 21:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230272AbhFKEXr (ORCPT + 99 others); Fri, 11 Jun 2021 00:23:47 -0400 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:45428 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbhFKEXr (ORCPT ); Fri, 11 Jun 2021 00:23:47 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R601e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=yaohuiwang@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0Uc0WV3Z_1623385308; Received: from localhost(mailfrom:yaohuiwang@linux.alibaba.com fp:SMTPD_---0Uc0WV3Z_1623385308) by smtp.aliyun-inc.com(127.0.0.1); Fri, 11 Jun 2021 12:21:48 +0800 From: Yaohui Wang To: dave.hansen@linux.intel.com Cc: luto@kernel.org, peterz@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 0/2] mm: unexpected behavior of __ioremap_caller Date: Fri, 11 Jun 2021 12:21:45 +0800 Message-Id: <20210611042147.80744-1-yaohuiwang@linux.alibaba.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Due to some boundary calculation & boundary judgment issues, __ioremap_caller may not work as expected. This may raise the risk of misusing ioremap_xxx functions, and further, incur terrible performance issues. For example, suppose [phys_addr ~ phys_addr + PAGE_SIZE] is normal RAM. Calling ioremap(phys_addr, PAGE_SIZE-1) will succeed (but it should not). This will set the cache flag of the phys_addr's directing mapping pte to be PCD. What's worse, iounmap won't revert this cache flag in the directing mapping. So the pte in the directing mapping keeps polluted until we use workarounds (calling ioremap_cache on phys_addr) to fix the cache bit. If there is important data/code in the polluted page, which is accessed frequently, then the performance of the machine will drop terribly. Here are two patches addressing this issue. The first address the boundary calculation issue and the second one addresses the boundary judgment issue. Yahui Wang (2): mm: fix pfn calculation mistake in __ioremap_check_ram mm: fix boundary judgement issues arch/x86/mm/ioremap.c | 4 ++-- kernel/resource.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) -- 2.25.1