From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 11E11220681 for ; Thu, 9 Jan 2025 13:38:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429906; cv=none; b=igIdEdXvsUYlFvGRSiHjKUkEG0ktmDjDs8uECiHvRR15Kgn1yVN1uewWZcE9CzHzoNDa0S7TAfjoSQ4kiKY+HahMWUU6/o58GG5TcgxfMFoFUatFftM7PQKKVsNBWpXEYV/dyg7m3MClZ7N77hgmz7Dt6zkz2NryJC/jCJoXgis= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736429906; c=relaxed/simple; bh=tj0EaTI4xDK9nr89rwD+fHqfvdYzjn0WO9cVa0FoTrY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GUR52Z+sueK9MBeoLc1BroLCdRNmbu7GZPmviVIeeKwoCWlA8lwCXIGVzCrSnnsWGITJeDYKyYBmvMtIqJRmZNcII+hiNxpfVVReI4UA5Ty/Ti7eqE0KE8kRKbsyNO6+fK+XOVObb36ZGmf4bBQDgzLW8Cf3KfWWNbRhy4Fjsz0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=g0CYqKVc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g0CYqKVc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736429903; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=uldQPwdfE7L9Dk1HaWI6s1M7Pg4/zwkf9XHa0qYWEsU=; b=g0CYqKVcQd1mTUJcZ3pSyxrL9khVakQuQG/SAl9944TRmV3XiBzuYDE6z68cWu6f5nj5LW dS+ads4yr1+MezLy2IcR7Ma4FWZiJNtumi5xSstAHXdpVMiTDGhhGpPAT6lVZSd+6oqjRA uTRTy618tXqwZ9kCTlohb5KK252IqVQ= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-227-1A4RfrQAOXyvh4EXtR3Oxg-1; Thu, 09 Jan 2025 08:38:22 -0500 X-MC-Unique: 1A4RfrQAOXyvh4EXtR3Oxg-1 X-Mimecast-MFC-AGG-ID: 1A4RfrQAOXyvh4EXtR3Oxg Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-aaf9d0f4e0eso84050766b.3 for ; Thu, 09 Jan 2025 05:38:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736429900; x=1737034700; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=uldQPwdfE7L9Dk1HaWI6s1M7Pg4/zwkf9XHa0qYWEsU=; b=BfsoUP6OceqItHGl1w5EI2aTmBZYlDtmC7/+VbW57Ka2w247JlTy78UQJjc1Mqq8pf d30elkSoQW6oA5lSOo3XRafTnQzjjZ2j2XamkmwZi8enb9/iB4XKUc0BhK9MmTrK1ph3 vqChyZ0vrxkEOI3umgyPQQAYSu9Vye8k/Jw8Wr1KJwwEZ2QmOzqNQ98ZHsHUjjiFzJ7x hO8nLZP9UXH0VXMdpT0mdpqJDIkgnrT/xVeNL3jWcXhnga3RrTC4vAJE0J7h3Jgt5V0T 3pxZieAOQ8MlF/Q5rbvrCtybm4ZGBvXJWIymSQxBHtIIZ3mO7lrkl1+nBpXZL6pJIqeL rKEg== X-Gm-Message-State: AOJu0YzGC7nI+GPu88I1rXQWJL53K+XnzAWTD1Vx7NsF5Yp2PD7ojcOg jmHMf3hAnV5BDI/FWLtsityvePEwSpkryMYYwHb/z0D4NKnRClMEQaNa4ocClmmp5ThwjWqCjoy wg3IVa9/36FYBhxgXtrWnWi87yWB75pe+AX+NW2R6x2CCXsBghjmORwVG8IUv0imHmckkvfT/b6 9mR6mj/OvB2lSbDLZ7aAuCcFWr3/wKXxhcofrdzi83s5OQ/SdT X-Gm-Gg: ASbGncsRjlM4+8aF0jkkCRth7DEsn8tvPSoAdRbLRH5zbi4TQFYgW8Bk+4jq78hm3XN 90IBEcg4Uo30OC9Zs4ApjKarJ34zdTnVsqk/GM73rbCX5IbvTLA8Ha0mn74XFs/kR4d+vE6fxH7 uoF7W+Pjj9c4gpnN6PNWvq75LNmiJcxcBcVj6n+zdfDACvOUTD0ckfAgL0pMuDQbHiQyekoy/Iw xNcY/2p29T4mvwdGXkKUkjmK91iqRb0PMkQee9dhiqdwR293R7J0jIbtHFY X-Received: by 2002:a17:907:36c8:b0:aa6:4494:e354 with SMTP id a640c23a62f3a-ab2abc92570mr698467266b.42.1736429900356; Thu, 09 Jan 2025 05:38:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGidjwN/yFK9ZauIimr2u7AiwN7b2XDO8B6ecoGAlxpK3GFkQSMXGdYvA9XVkfNkK6maNXm2Q== X-Received: by 2002:a17:907:36c8:b0:aa6:4494:e354 with SMTP id a640c23a62f3a-ab2abc92570mr698462166b.42.1736429899595; Thu, 09 Jan 2025 05:38:19 -0800 (PST) Received: from [192.168.10.47] ([151.62.105.73]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5d9904a5277sm591739a12.80.2025.01.09.05.38.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2025 05:38:19 -0800 (PST) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: oliver.upton@linux.dev, Will Deacon , Anup Patel , Andrew Jones , seanjc@google.com, linuxppc-dev@lists.ozlabs.org, regressions@lists.linux.dev Subject: [PATCH 0/5] KVM: e500: map readonly host pages for read, and cleanup Date: Thu, 9 Jan 2025 14:38:12 +0100 Message-ID: <20250109133817.314401-1-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit [Oliver/Will/Anup/Andrew, you're Cc'd because of an observation below on VM_PFNMAP mappings. - Paolo] The new __kvm_faultin_pfn() function is upset by the fact that e500 KVM ignores host page permissions - __kvm_faultin requires a "writable" outgoing argument, but e500 KVM is passing NULL. While a simple fix would be possible that simply allows writable to be NULL, it is quite ugly to have e500 KVM ignore completely the host permissions and map readonly host pages as guest-writable. A more complete fix is present in the second to fourth patches (the first is an independent bugfix, Cc'd to stable). The last one removes the VMA-based attempts at building huge shadow TLB entries, in favor of using a PTE lookup similar to what is done for x86. This special casing of VM_PFNMAP does not work well with remap_pfn_range() as it assumes that VM_PFNMAP areas are contiguous. Note that the same incorrect logic is there in ARM's get_vma_page_shift() and RISC-V's kvm_riscv_gstage_ioremap(). Fortunately, for e500 most of the code is already there; it just has to be changed to compute the range from find_linux_pte()'s output rather than find_vma(). The new code works for both VM_PFNMAP and hugetlb mappings, so the latter is removed. If this does not work out I'll go for something like https://lore.kernel.org/kvm/Z3wnsQQ67GBf1Vsb@google.com/, but with the helper in arch/powerpc/kvm/e500_mmu_host.c. The series is compile-tested only. Christian, please test this as we do not have e500 hardware readily availabe. Thanks, Paolo Supersedes: <20250101064928.389504-1-pbonzini@redhat.com> Paolo Bonzini (5): KVM: e500: retry if no memslot is found KVM: e500: use shadow TLB entry as witness for writability KVM: e500: track host-writability of pages KVM: e500: map readonly host pages for read KVM: e500: perform hugepage check after looking up the PFN arch/powerpc/kvm/e500.h | 2 + arch/powerpc/kvm/e500_mmu_host.c | 202 +++++++++++++------------------ 2 files changed, 89 insertions(+), 115 deletions(-) -- 2.47.1