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: 13778437 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E2E49C5472C for ; Mon, 26 Aug 2024 20:47:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gD9ggS8OhpZf/NsZoH3fZjUIikns33eAnWwzmGyUsEI=; b=VIuXGhaXABkMUnteQ2PYcck6xL DC5T+Wtqw27FiAHP9mCKu+dJg6glwZcFZI+yFjXyqFef+NtqC/WBaFnaL6pragBdq4ZaHeUkgdDdp fqVQxElP1sQvd/2HvG0UHgGDCTAHkFr07cSdIk4W27jyOW23ekF6VQLS5HXGCSLHcPHV9YvxHmgxq Sm9zs5ayabsI0LWgmApPJPalSECYUmzaMLn7ViZ8ySDCBukDm/KjQlWYGJGwqTbR0gcyV843RuoWO m6ktSKAFJhft14V4J0SLcGrqiRLU3uEZxtG+ijZ38EbYqQSIWA0bs2tPcPgC04MjnxvHBv20Tz46f 0TyCWUAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigcU-00000008fck-2tZP; Mon, 26 Aug 2024 20:47:22 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sigZJ-00000008eLw-1eet for linux-arm-kernel@lists.infradead.org; Mon, 26 Aug 2024 20:44:06 +0000 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-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-367-8E2RMll4NoutypmRop0dlQ-1; Mon, 26 Aug 2024 16:44:03 -0400 X-MC-Unique: 8E2RMll4NoutypmRop0dlQ-1 Received: by mail-qk1-f200.google.com with SMTP id af79cd13be357-7a66bf35402so589826585a.3 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=DDIzv7ZfZuoDm6xIP2ILiOZ0Gk1RVlJG7PNrLXPQZXCqYxg4Jrd2hQt59TjU6Njvr8 ib5Fwb7NzsiB2p9BfDAleBfnIuk0zI2e1MfiLkN1o++yFuo7V4jOeofDrjDFdBsR5kwT /8CawOGtYLalj7Na5uc4PxQuiNc9h/NRenz4Qf5+q/vHaagIwy7Q+OfKJGiZfA5Rq+3W AYZzyDg94eldc1lKhELHT4RR8cfabp37H+gk4E3XHeqnhXRSGaxrvboMspt5pecQ5zZY wmTm1S2oqfLLRfdmLLlAoOyrsdEGSle5b+LuWkL0G1BpUUoQUQP+FsWv/JiNsD9JtLXE mGmA== X-Forwarded-Encrypted: i=1; AJvYcCXYzQBOwfHmx5h4b8Kee14OV4TPcO7ao8oY6RF3Z1f4hCd6vlbfMkjQv0vLUHpJoSf1fcOkwux2TlMjCcz5ZEuS@lists.infradead.org X-Gm-Message-State: AOJu0YzH1rjjCrFH0b9ih1WJO6MucL72CYYYKtPf5smTwqkMj4IcIucj Ama+LU1A7O154AMnWVqvKnYyyv9w+xKTLl5w15FbRwGF9sTgd19AJ3VURGkmf7IB8S88IOPjoth plBzFXfnRQQNyGHMnIDwjVQSLn0BuT/qazMpu0iZt6q1ssjMSEIc6S7gQ7JAsMTqbl8JEk14q X-Received: by 2002:a05:620a:24d5:b0:7a3:6dd9:ef9d with SMTP id af79cd13be357-7a6897c6e76mr1277666585a.62.1724705042591; 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240826_134405_529893_C9596016 X-CRM114-Status: GOOD ( 12.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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);