From patchwork Fri Nov 29 12:39:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikita Kalyazin X-Patchwork-Id: 13888632 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 77A9AD6EC04 for ; Fri, 29 Nov 2024 12:39:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E7B1F6B0085; Fri, 29 Nov 2024 07:39:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E2AE56B0089; Fri, 29 Nov 2024 07:39:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D19CD6B008C; Fri, 29 Nov 2024 07:39:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id B184B6B0085 for ; Fri, 29 Nov 2024 07:39:42 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3A48F40D10 for ; Fri, 29 Nov 2024 12:39:42 +0000 (UTC) X-FDA: 82839088584.01.A789E5C Received: from smtp-fw-80009.amazon.com (smtp-fw-80009.amazon.com [99.78.197.220]) by imf21.hostedemail.com (Postfix) with ESMTP id B3FA71C0002 for ; Fri, 29 Nov 2024 12:39:24 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b=v1X4Ks2I; spf=pass (imf21.hostedemail.com: domain of "prvs=0560a7136=kalyazin@amazon.co.uk" designates 99.78.197.220 as permitted sender) smtp.mailfrom="prvs=0560a7136=kalyazin@amazon.co.uk"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1732883974; 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: references:dkim-signature; bh=mR0/WZBsSVJKyzUHx1nK1XmzVfPcIwiHMj7Qmp6UTCE=; b=VrsugAvT4H2VeSZOnYcVojF2XKZbA5hkXU1vYlqOjVSbk3CtnkVzsV8xzl2TMvzQvuv+EU 0XGuDQPGyS5W1QtKdSoYsfxacmitKZWii0BxSkuco0OpIMDJ2+gqB4BbqvachCvbnl+UfZ TjUTbQrw0WCktxvjUJaqNL6skpCfzw4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=amazon.com header.s=amazon201209 header.b=v1X4Ks2I; spf=pass (imf21.hostedemail.com: domain of "prvs=0560a7136=kalyazin@amazon.co.uk" designates 99.78.197.220 as permitted sender) smtp.mailfrom="prvs=0560a7136=kalyazin@amazon.co.uk"; dmarc=pass (policy=quarantine) header.from=amazon.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1732883974; a=rsa-sha256; cv=none; b=K2jHnYkCWylTFAgzLD8UM5rb3wVVWP9rao+ZpVk5ibESfOFSQ/87mmhErCZ/qKY/Ma3/9n U5CX5w2YBjdyvOzyPto9QfbU+nieZBDRyNrEy/VVumBWTVefSvu48OLzKR3QfkQ5JH2H6n HdF/fjU3CyjL+ZFEyEXnvsqrT6+fS9o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1732883980; x=1764419980; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=mR0/WZBsSVJKyzUHx1nK1XmzVfPcIwiHMj7Qmp6UTCE=; b=v1X4Ks2Itu6VGPIgLPxmqXscMvXGXmmpoCQ49aBhRh1vEDAxwEldzQck dhJQWuvWXobgFhJSMjOthPhA6BTEJjw3OaynapDVfvLhDJUqgNlJ4W2bI lCqOZrieA1T0Ttk0aFMyS8l5DnT2BtA6nSiaGsWpu8Hpw6vmIspKGrS/f Y=; X-IronPort-AV: E=Sophos;i="6.12,195,1728950400"; d="scan'208";a="151746608" Received: from pdx4-co-svc-p1-lb2-vlan2.amazon.com (HELO smtpout.prod.us-east-1.prod.farcaster.email.amazon.dev) ([10.25.36.210]) by smtp-border-fw-80009.pdx80.corp.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2024 12:39:36 +0000 Received: from EX19MTAEUB001.ant.amazon.com [10.0.10.100:7366] by smtpin.naws.eu-west-1.prod.farcaster.email.amazon.dev [10.0.32.84:2525] with esmtp (Farcaster) id 04dd6e55-c77a-4f11-99e2-29083b9202bd; Fri, 29 Nov 2024 12:39:34 +0000 (UTC) X-Farcaster-Flow-ID: 04dd6e55-c77a-4f11-99e2-29083b9202bd Received: from EX19D015EUB003.ant.amazon.com (10.252.51.113) by EX19MTAEUB001.ant.amazon.com (10.252.51.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Fri, 29 Nov 2024 12:39:34 +0000 Received: from EX19MTAUEB001.ant.amazon.com (10.252.135.35) by EX19D015EUB003.ant.amazon.com (10.252.51.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34; Fri, 29 Nov 2024 12:39:34 +0000 Received: from email-imr-corp-prod-pdx-all-2c-c4413280.us-west-2.amazon.com (10.124.125.2) by mail-relay.amazon.com (10.252.135.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.34 via Frontend Transport; Fri, 29 Nov 2024 12:39:34 +0000 Received: from dev-dsk-kalyazin-1a-a12e27e2.eu-west-1.amazon.com (dev-dsk-kalyazin-1a-a12e27e2.eu-west-1.amazon.com [172.19.103.116]) by email-imr-corp-prod-pdx-all-2c-c4413280.us-west-2.amazon.com (Postfix) with ESMTPS id 10084A0504; Fri, 29 Nov 2024 12:39:30 +0000 (UTC) From: Nikita Kalyazin To: , , , , CC: , , , , , , , , , , , , , Subject: [RFC PATCH v2 0/2] KVM: guest_memfd: use write for population Date: Fri, 29 Nov 2024 12:39:27 +0000 Message-ID: <20241129123929.64790-1-kalyazin@amazon.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Stat-Signature: nsz5cy1qpcsyihpd8yrzmssma4ofaxyp X-Rspamd-Queue-Id: B3FA71C0002 X-Rspam-User: X-HE-Tag: 1732883964-727960 X-HE-Meta: U2FsdGVkX19DSu32FAwO15RSThRUhrj71/ULDMec/9LjqQLjle5xNPO7wM/HsdHcvYhEuqLgceP+w/DbBxlVL+iJMIHVlz0xYQ1eXosoCR+na2TKp6GIM6DzzgpgcqYOK0lJ7B2UhzWLdLhfvlPojaVV8jspzDCBuQBc+LI+CUSc7e1SNgT/0hDS5h25rOke0BEzsR9Mzq2SjTP9nUAUt8PG7kHA4DE5jB0A6H8p2TsweX9nhXTkoP1ZeU8cb/F6hIa8sco5saOBuTD/rnppOuA7Wc65DDaoQM6yftr86HjJf/AAfId64jvsK4WYgyKladnJRIzGyRYY2PkRvdKJVnOkZSXJ9Y46pRjdBl8W2SBp9EGhG51ZFNJYPb+Qw/FbAqp1wK7wdD12bY3vcQXLNyqYGcZMMVr7wGmVtFCJR6e3fMl+RaIOVD+2Y1yMiJZs8faFqwxN2qLU6y7bidtPgRJ2RRv/CA3lI8GYTQ96LCtZSmCObVLEr4gz3nJHSz0RiUP12U04PPh4C9qOdw+IDACp/SWrrJDz8JE9X8hZwDvHKCxcKKXc+3j6Yz+clra078J8cm+jXaJMDGl/POtZ9ClYvsRW+XS+BuP6Of67RNl591U0OTxQBRCfRmPl8L4VYiknvW8EVPMc5J/9LJZ2CCfNnlR1Y3PhbJi6qWbz57iyvL3Qd7436iU0/ZnQT367JkCiXbuBjz0uhxitKaNzTUpoIHWMLYvsqIlxM8Y/8nd9PriNmm4aEvoSySLW0af7nhMoItCwr+rg4vuSQQPIH5RiRexSSD0FguqK33vousI1tmS8VkPgOmutzA6lJx/za9z5gQL9eqo9bx2Cew9fw0CRi/1i7aWMgrDZsG55qDgzTYtwG9wSfcuk4iz4+G+DwlHHoCHv2oAiZERInsqhI18OYbd7aabL+DY9L975gXbDGIZ5V8pl8FSpKAxuuXSf7oR/xOnqajeYW3TiTm/ YaGmvvmU Ade14faAtRqSklM8cvlQGoy7ZJkJ84P9a8OSZu0JEtqyAIRY+X/pEJQ8EFU2bycG+DHDKFyYuLL71vZucb0cudAT9EndN9bkkfVQCrfY7Nh35/8yx1UIBaoI9NHGBdUE1x/+rmnZ0ZMqT6SGJrQA/iAF0XiOSq/UopqIBMexqOZyYrIS8EFnJWFx11OcJODZroYSpehQb/60hyHceu8S0/8N9SvRs3Om9Dw2Ed6s+VMQsAh7dx2DppxKuMr0W4+BSc5Wa5BS7j0e6c5TdezLfxWojrlGUuKBBIW/jWDastmANLNsxU3KcTNGxIE4xS3g+JpZI8A+ZFza/2eGMUHAsYq9khQ/NgGAy3pZX7D1L6YfAcxujjlA2uZVcNVtu6sERsEJqG1EyyZ+eopBNdZVtY9ykRvaSQyxRyYJ+ui4zfJl9ga10uc2rkVmXE9orPY+HGCveN/CotumX6gpD+qBsxl9T4FFAt7cKL8XRXmdyeiu6Zr0A9AS9vNH7PRzdcw40Rajrar6OOzDMFoaRxHbprnovFD9PmnqcBuYMkUzIUzoJRcFGtcTVh7ZCX71PbouwwmX8 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001763, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: As discussed in the v1 [1], with guest_memfd moving from KVM to mm, it is more practical to have a non-KVM-specific API to populate guest memory in a generic way. The series proposes using the write syscall for this purpose instead of a KVM ioctl as in the v1. The approach also has an advantage that the guest_memfd handle can be sent to another process that would be responsible for population. I also included a suggestion from Mike Day for excluding the code from compilation if AMD SEV is configured. There is a potential for refactoring of the kvm_gmem_populate to extract common parts with the write. I did not do that in this series yet to keep it clear what the write would do and get feedback on whether write's behaviour is sensible. Nikita [1]: https://lore.kernel.org/kvm/20241024095429.54052-1-kalyazin@amazon.com/T/ Nikita Kalyazin (2): KVM: guest_memfd: add generic population via write KVM: selftests: update guest_memfd write tests .../testing/selftests/kvm/guest_memfd_test.c | 85 +++++++++++++++++-- virt/kvm/guest_memfd.c | 79 +++++++++++++++++ 2 files changed, 158 insertions(+), 6 deletions(-) base-commit: 1508bae37044ebffd7c7e09915f041936f338123