Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3352758rdb; Wed, 13 Sep 2023 09:25:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdU0IMH7/vBNR6qWAyrNJEK8pHI0cV5VfgjsYaPFvEiwakmK0AhXwwhuxTKE6sTa1h7mEG X-Received: by 2002:a05:6a21:47cb:b0:14c:76bd:10c1 with SMTP id as11-20020a056a2147cb00b0014c76bd10c1mr2563087pzc.21.1694622349287; Wed, 13 Sep 2023 09:25:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694622349; cv=none; d=google.com; s=arc-20160816; b=Y8iayRPfJiqoh1erajTZ8ybr1LmlK2g6lm1I9K0HalDcGxJBUO01XjhPR/VXJ/RWx+ Q6dHbKu0NNaw5AMlGTk2BQc0wwFZV0JNVHW239CTnv0hr7X0l6saEBbpdfjRJrUTclQ+ HDlpqjbXVyh1VAe18Xrsjt7mKrFhfdE73ajQmOXJCqqy/5W68c9x1V/vPy+AB12gEiZ0 87PnATDibJjyAeXVXYeIC+qmRBpBHm5oc3DN345ONPJuEvLMZxvgseCBNnGeK3PlpBIz M9vOyRAOAXGVRhaKbrYtzhW9p9sybrLxarw5dRHPskPCuQh1IV/SLJFN5zv196pX3Z/d wJ3g== 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:dkim-signature; bh=k9rSHVerpncRa4wBYdOIB5UwrgFcJJQyOqnMl9zPk5I=; fh=ANS6iRpdj3ntKSmwSzT4LEHUH9ZAudCj9zvP8/EeThQ=; b=cH0a+EKVrRIExvpS137mxXPBdTqvUkNtw23K+I5ntYUKGEayF4z+L44PWI1lJRMpYI b+UO3cenq8CCLBpHyc5aSpSHlaIW4qGLMaK5ZrjowlWzD/WLoa64WEGh1AetTvdMUdYN HS3GfMHV2tVUzjxTw9H2DwvwWKbkQJtL8wbWHuvEdsCgb/oPY1JpWueRyVWA+SQ9Gn/d /crp5hxMpghtWBoS78MmvNsru5YrJt9yWZ9uth8NUyi5ACJy/LPv9bkVlnuTYkrTU8zd cocYZC0jfl4xwVD0+r+/xYWTMga8BmThWB+aIvNCyA6SJM14cpUqzlJF0u9eiIMY5xK7 PhCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kw3R2kQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id q7-20020a170902a3c700b001b9e1d5f8e6si10477158plb.447.2023.09.13.09.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 09:25:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Kw3R2kQm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id F1D7F8268131; Wed, 13 Sep 2023 03:49:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239718AbjIMKtN (ORCPT + 99 others); Wed, 13 Sep 2023 06:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233278AbjIMKtL (ORCPT ); Wed, 13 Sep 2023 06:49:11 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 049ACCA; Wed, 13 Sep 2023 03:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694602147; x=1726138147; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=0ipY0xZJYgdQ7/oanIvGLJbsO2u+4QkUIghXmzX8/8w=; b=Kw3R2kQmyEQ5Zwc0wbCb2Yd7fPT0RznIWyCi2ft42LzDu2alxOYXHlop bQgcDFexSuRY0JgGV8d2JLLnkNzrU6nA4f59ZllQoBnV8aEX8vXxtyI/D ObfoE9849aTywudPQ35dKOHAixQrJG/4cuf0ohCaQ2bbfS1Odaszf222f 4kZ3pEpJA/PIbLBppqJt4f901jhsbMg5/q9DZVNT5YPLE1fbmKdzkxUVW faHT0EdHXD96Q0ctNBNTO9SuXe5KTQPz5Q+FCnsCJNAx7y+UyejHUvyKs 9uInDqmf3HjpYoRjtTzitIzgP8ABssf8AJMPvi0qHNYNFLt7gFRlKLbAw w==; X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="464994921" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="464994921" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 03:49:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10831"; a="737451848" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="737451848" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 03:49:06 -0700 From: isaku.yamahata@intel.com To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: isaku.yamahata@intel.com, isaku.yamahata@gmail.com, Michael Roth , Paolo Bonzini , Sean Christopherson , erdemaktas@google.com, Sagi Shahar , David Matlack , Kai Huang , Zhi Wang , chen.bo@intel.com, linux-coco@lists.linux.dev, Chao Peng , Ackerley Tng , Vishal Annapurve , Yuan Yao , Jarkko Sakkinen , Xu Yilun , Quentin Perret , wei.w.wang@intel.com, Fuad Tabba Subject: [RFC PATCH 0/6] KVM: gmem: Implement error_remove_page Date: Wed, 13 Sep 2023 03:48:49 -0700 Message-Id: X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Wed, 13 Sep 2023 03:49:15 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email From: Isaku Yamahata This patch series is to share my progress on the KVM gmem error_remove_page task. Although I'm still working on test cases, I don't want to hold the patches locally until I finish test cases. - Update error_remove_page method. Unmap gfn on poisoned pages. Pass related arguments. Unfortunately, the error_remove_page callback is passed struct page. So the callback can't know about the actual poisoned address and range. The memory poisoning would be based on cache line size, though. - Add a new flag to KVM_EXIT_MEMORY_FAULT to indicate the page is poisoned. - Add check in faultin_pfn_private. When the page is poisoned, KVM_EXIT_MEMORY_FAULT(HWPOISON). - Only test case for ioctl(FIBMAP). Test cases are TODO. TODOs - Implement test cases to inject HWPOISON or MCE by hwpoison (/sys/kernel/debug/hwpoison/corrupt-pfn) or MCE injection (/sys/kernel/debug/mce-inject). - Update qemu to handle KVM_EXIT_MEMORY_FAULT(HWPOISON) - Update TDX KVM to handle it and Add test cases for TDX. - Try to inject HWPOISON as soon as the poison is detected. Isaku Yamahata (6): KVM: guest_memfd: Add config to show the capability to handle error page KVM: guestmem_fd: Make error_remove_page callback to unmap guest memory KVM: guest_memfd, x86: MEMORY_FAULT exit with hw poisoned page KVM: guest_memfd: Implemnet bmap inode operation KVM: selftests: Add selftest for guest_memfd() fibmap KVM: X86: Allow KVM gmem hwpoison test cases arch/x86/kvm/Kconfig | 2 + arch/x86/kvm/mmu/mmu.c | 21 +++-- include/linux/kvm_host.h | 2 + include/uapi/linux/kvm.h | 3 +- .../testing/selftests/kvm/guest_memfd_test.c | 45 ++++++++++ virt/kvm/Kconfig | 7 ++ virt/kvm/guest_mem.c | 82 +++++++++++++++---- 7 files changed, 139 insertions(+), 23 deletions(-) base-commit: a5accd8596fa84b9fe00076444b5ef628d2351b9 -- 2.25.1