From patchwork Mon Aug 26 20:43:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13778397 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 9756CC5472C for ; Mon, 26 Aug 2024 20:44:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CB506B0088; Mon, 26 Aug 2024 16:44:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0DF1E6B008C; Mon, 26 Aug 2024 16:44:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E740D6B0092; Mon, 26 Aug 2024 16:44:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BD8006B0088 for ; Mon, 26 Aug 2024 16:44:07 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 72D131A13AC for ; Mon, 26 Aug 2024 20:44:07 +0000 (UTC) X-FDA: 82495573734.24.4108886 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 4B428140022 for ; Mon, 26 Aug 2024 20:44:05 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q82x8+X8; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724704959; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gD9ggS8OhpZf/NsZoH3fZjUIikns33eAnWwzmGyUsEI=; b=ZpkYAC4MQwJYimCTT8TB59FgIoStZAhEXYzNUuCFYqJmisctzFvzwtv8Jd6M2c/jfFH3jH KaXJ8C+wifB/rbP0vGPE7xyUXZg7CilX/qoJmq1Sp8Rjhv1Ix2epKBtbUrneUFDeNTZi6I KB8uxhY6qoz338oCEmjPPx/BqHEB64A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724704959; a=rsa-sha256; cv=none; b=CyCTrKygf8uHzqjmV3sZQOhyWqHoSj3F2qWM+QPNuKygS5EPTNy3xQm/o6kVjKkUzGW25+ nKBrzpm/mTEe/fJN2eW9nyRo5PWQBWAsR9Cw99qtOFHhS2sFBqjHBl144lUwnWqRW5+pYs 5AldnExKm9OfovIluXLvADNNpbuOIXQ= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q82x8+X8; spf=pass (imf09.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1724705044; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gD9ggS8OhpZf/NsZoH3fZjUIikns33eAnWwzmGyUsEI=; b=Q82x8+X872PXGlQbC3y0v165wX4+CBhWfdMjlxbb5gyJBg3sWC+VmG56BDyVDwPge//L4r 2AAhQMj6yIt7eTaxQ/0tAUTtdn2VLO4nYJDKAKVdidhju9qJ5T3T2H9IE4QB75mOkD9C++ kJ/gQPPHLXAv/nQHi2JoxTHcXufRmW8= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-670-RDiWEq-dPdOs3yy6ysqrxA-1; Mon, 26 Aug 2024 16:44:03 -0400 X-MC-Unique: RDiWEq-dPdOs3yy6ysqrxA-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-7a1de8a2af2so745173685a.0 for ; Mon, 26 Aug 2024 13:44:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724705042; x=1725309842; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gD9ggS8OhpZf/NsZoH3fZjUIikns33eAnWwzmGyUsEI=; b=cDRuHPbrxB7Vtfahnfk/hqeYbLweyaq7JB8rdBbJZ3/g6UDYqfHzoplKKDJRfGKYj5 qktM9rDlUwKSMOO7skWFko7MIh34V83BjYEd9XV/813jzMYwpc9hh/ITdxiR9OxuW2aI kApcil1aOWu+XwmcTBAIWGF/U7bDYZyPDfz/OVWTkBEyO2h6X9c7wX1lsoPhRHXShoQR Q3ClAgm3tAdCp/+F5wcVQLBresDXVLYZNeqM286a96R8VKYeAfbD0gKoOMQIn6ydn1Oz CVrQYOuGZL1x4vuQ87zw/Ja/VO6VAdLoOo3+12RZ7vdu4GXrsxLlln44KMlRNyBFPL22 hdcg== X-Forwarded-Encrypted: i=1; AJvYcCUP9sHw9cffarSrFafM76EOEwfd/o+YWsYmPMCxtqKTM38G3/SAvFOQQuRRcvVAvpuKD5ix2YfI/w==@kvack.org X-Gm-Message-State: AOJu0Ywzm3x/lFaMH8F+CkoloGEsizETyG53xlAf+INCNC2xPN7dNVTi DavS2/qo+eYDU1oDLSXwryq7xzLD+FIWRUiZX71Gu4jZVRLA2RNmsVwStIEIuIvbS0AHxXua9Qc KrY238/hiEm04cuRHPrz86dcvoLKbkvupc15twRsOpel4sfLY X-Received: by 2002:a05:620a:24d5:b0:7a3:6dd9:ef9d with SMTP id af79cd13be357-7a6897c6e76mr1277666185a.62.1724705042583; Mon, 26 Aug 2024 13:44:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIqrjqvJMs9Ym5fhhSHDCZDk2wQ6104PL5R9Vk0hTAFm1CUlIqFGQmzGdyDHGQhWdDyxioXg== X-Received: by 2002:a05:620a:24d5:b0:7a3:6dd9:ef9d with SMTP id af79cd13be357-7a6897c6e76mr1277664185a.62.1724705042003; Mon, 26 Aug 2024 13:44:02 -0700 (PDT) Received: from x1n.redhat.com (pool-99-254-121-117.cpe.net.cable.rogers.com. [99.254.121.117]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f3fd6c1sm491055185a.121.2024.08.26.13.44.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:44:01 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Gavin Shan , Catalin Marinas , x86@kernel.org, Ingo Molnar , Andrew Morton , Paolo Bonzini , Dave Hansen , Thomas Gleixner , Alistair Popple , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Sean Christopherson , peterx@redhat.com, Oscar Salvador , Jason Gunthorpe , Borislav Petkov , Zi Yan , Axel Rasmussen , David Hildenbrand , Yan Zhao , Will Deacon , Kefeng Wang , Alex Williamson Subject: [PATCH v2 03/19] mm: Mark special bits for huge pfn mappings when inject Date: Mon, 26 Aug 2024 16:43:37 -0400 Message-ID: <20240826204353.2228736-4-peterx@redhat.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240826204353.2228736-1-peterx@redhat.com> References: <20240826204353.2228736-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 4B428140022 X-Stat-Signature: nwxqnifw93p7y5u93uygejfag1cf5epx X-HE-Tag: 1724705045-679792 X-HE-Meta: U2FsdGVkX18git0ZviYHVAcOWx0AWYLWKPoS2Mu0L9Ij7wjNdz81yuAAsZeM6upzPtxMLzNxu5q2opOS2KAHF+FhPjLZ1wc5g+LFbJAzKmKDVm7jVziV/z7cPDplCAv6P43k2VvV/jykxaM+p+4Mv5Ka+dLAE67/yleOTgY1YQWDrr/fAN3y4sTCVo4Tpn5yyKbelLxfxlD4ecOlFkXHzjjuniD1JS8OtRNBKhFY7rq3MLZpt/crTUTGuvtvqa3CedUWAKfhGSnAQFt+Tdw07DrvAwmn3dYddQ3rVUFojhbxE1bPkcrLJHNwWAEYSq7HgDKySeFRBu69Vouy6CDxXeKWccouwLGeTSS0sf6h3M/dAEII+DhWA5w4bU7juOwS+CzoonhfXfog6Oz7Q574joFawQ2myibP5MQC8MRhpPW1foHI/99tqJexRzs9jf7B7st7eCgzF+uG2s1nzABUJoTkQg0gnnYiUTXl9+wjCDGNn5QgTsypT6Thgt5Jd4DypAkBE0FJ8Uv2UkS7vCXoP5YT7oimK3OJqdDBDm6CHND0dU0z9IdR+An7UR3KsXO7bN9o0iVRv2ePwZiKFou1e0ityNzfPTXdpah8tnI672mXS8NZ5li5v1mc0aDeBnSmgH0zeQ+Tj9bsVVbDwuu1pHgU0VgHIljQz7o0anxYhs9QmtsfksmHJhSo+1aiCzkKdyZEF2+lQRIPCtWOhApf1JyN0RreuHYSucrEZh3pWcppW+gVITqvTqltXkcHFsTT+NMBzeZKzpFixztT3WS/XTtsnLRiyaw1KefMbgJ0nyM6XkKWXNfLzdCG6SqVUnq7u+Y2JsdxG4uOSxX9+erYdpbPlsX7+B6deQFGKp8a+xAM3e5YWw9fJ126yQQhePbRe/KGECCiMN98SJ+xF4ppxtiLK2CfTS7Osw7OAZeA4a2EqGEjoSAbBZUb0ES7E5E26jG9C1bslMzBhTl1g+8 6yMyca9/ zuqQDjRiuuiQU2TGhKup2WJDnD46fjX4W1/B4v2aQRKwOijDxsEsHl+NYKl8Y5dxFSHGV6mAtLhLgWJN1sVPRuRz9a1ur1gJOZFw7qTgUtIT9aRyKiowlULV67dO5UdGlmQAZhZR59zBPdBBOC6prJ+Gt4XrzttZOARWX9RzLwEmIHdw29QQ/SYpmGQqK8F9mv+AMP9ddzJk7WCOpgpFgW8Sws+jgVRcffLB7IQy8Ho7aHiNiL+2isbco4wWBs2vxIHnPflkIdQcsfVe2dyB2wSYEJK+/UCPg/hOln15OfMzd/stUTDrM9ToG4X3l9LjMnYXk 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: List-Subscribe: List-Unsubscribe: We need these special bits to be around on pfnmaps. Mark properly for !devmap case, reflecting that there's no page struct backing the entry. Reviewed-by: Jason Gunthorpe Signed-off-by: Peter Xu Acked-by: David Hildenbrand --- mm/huge_memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3f74b09ada38..dec17d09390f 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1346,6 +1346,8 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, entry = pmd_mkhuge(pfn_t_pmd(pfn, prot)); if (pfn_t_devmap(pfn)) entry = pmd_mkdevmap(entry); + else + entry = pmd_mkspecial(entry); if (write) { entry = pmd_mkyoung(pmd_mkdirty(entry)); entry = maybe_pmd_mkwrite(entry, vma); @@ -1442,6 +1444,8 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, entry = pud_mkhuge(pfn_t_pud(pfn, prot)); if (pfn_t_devmap(pfn)) entry = pud_mkdevmap(entry); + else + entry = pud_mkspecial(entry); if (write) { entry = pud_mkyoung(pud_mkdirty(entry)); entry = maybe_pud_mkwrite(entry, vma);