From patchwork Sat Feb 11 01:37:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13136686 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 3CDEBC636D4 for ; Sat, 11 Feb 2023 01:39:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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=h9ErkutylJQtClr3FNobgfqEQ1PhXxtyeZ29Ql60VzQ=; b=klmhWqqPT6ezbW MiU2SiVf0U/jv06BRPw0vcojmzI0b0vO0KkjUUtbF7k5uzFb77ysFH3vR4AsfA6I/bb6v0tWjLQl2 Hne9xiSYUbtrZoypoQ5rDNXx2Kp4eF1GcE4wpMKkWTkrakiUMabxP91f+n4LoI6eB2I6texlljWo4 N+GFZitiNgX3Ym6tRGqe/KdC4nBIf9mcgjxJKDU9SmaHpKvZRfcQ6oN5r//DStvHukWGItjXW9+EZ XLXwb2qU6HhVtlvIerA/jgMtOcpxAWdpjBrQIJ2AVCXXswI1MZhl71SSO6QGUGzQ+bBpi3OaM5Sts gZDdmEwt7oqOfpaBzVgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQeqW-008F08-8w; Sat, 11 Feb 2023 01:38:32 +0000 Received: from out-44.mta1.migadu.com ([95.215.58.44]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pQeqH-008Ewu-9x for linux-arm-kernel@lists.infradead.org; Sat, 11 Feb 2023 01:38:18 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1676079494; 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: in-reply-to:in-reply-to:references:references; bh=uYKcrnYt5tqTigyH3lLK4W3VAbMxWX7++cvj3eUL8OA=; b=lOAAqD0vQEau104DxzBl5UeQ5ic6uEJOS06NzyWZhUFdOZriFHXvb22Avzooyb0wMOImdw jK7Ggub1wCbPfbnf8wy8rMiqwS75DFADbWLPPD29XXWByPC2g/9F5QBNcMoSKUgNg8Vr4y 3YXNoB8WemcB7I6oGfgHWsTFrQCbu4k= From: Oliver Upton To: Marc Zyngier Cc: James Morse , Suzuki K Poulose , kvmarm@lists.linux.dev, Akihiko Odaki , Zenghui Yu , Raghavendra Rao Ananta , linux-arm-kernel@lists.infradead.org, Salil Mehta , Oliver Upton Subject: [RFC PATCH v2 2/6] KVM: arm64: Add vm fd device attribute accessors Date: Sat, 11 Feb 2023 01:37:55 +0000 Message-Id: <20230211013759.3556016-3-oliver.upton@linux.dev> In-Reply-To: <20230211013759.3556016-1-oliver.upton@linux.dev> References: <20230211013759.3556016-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230210_173817_523424_1EAEF501 X-CRM114-Status: UNSURE ( 9.64 ) X-CRM114-Notice: Please train this message. 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 A subsequent change will allow userspace to convey a filter for hypercalls through a vm device attribute. Add the requisite boilerplate for vm attribute accessors. Signed-off-by: Oliver Upton --- arch/arm64/kvm/arm.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c index 9c5573bc4614..09efa893e03a 100644 --- a/arch/arm64/kvm/arm.c +++ b/arch/arm64/kvm/arm.c @@ -1449,11 +1449,28 @@ static int kvm_vm_ioctl_set_device_addr(struct kvm *kvm, } } +static int kvm_vm_has_attr(struct kvm *kvm, struct kvm_device_attr *attr) +{ + switch (attr->group) { + default: + return -ENXIO; + } +} + +static int kvm_vm_set_attr(struct kvm *kvm, struct kvm_device_attr *attr) +{ + switch (attr->group) { + default: + return -ENXIO; + } +} + long kvm_arch_vm_ioctl(struct file *filp, unsigned int ioctl, unsigned long arg) { struct kvm *kvm = filp->private_data; void __user *argp = (void __user *)arg; + struct kvm_device_attr attr; switch (ioctl) { case KVM_CREATE_IRQCHIP: { @@ -1489,6 +1506,18 @@ long kvm_arch_vm_ioctl(struct file *filp, return -EFAULT; return kvm_vm_ioctl_mte_copy_tags(kvm, ©_tags); } + case KVM_HAS_DEVICE_ATTR: { + if (copy_from_user(&attr, argp, sizeof(attr))) + return -EFAULT; + + return kvm_vm_has_attr(kvm, &attr); + } + case KVM_SET_DEVICE_ATTR: { + if (copy_from_user(&attr, argp, sizeof(attr))) + return -EFAULT; + + return kvm_vm_set_attr(kvm, &attr); + } default: return -EINVAL; }