Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp924752ybt; Tue, 7 Jul 2020 03:42:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJybQutIjdmtemi4IzDcE/Avy12glK9NWmF+BYqxso4UnBgx09pR/dxNZDohddMBK9py0nxo X-Received: by 2002:a17:906:82d2:: with SMTP id a18mr45890653ejy.522.1594118558753; Tue, 07 Jul 2020 03:42:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594118558; cv=none; d=google.com; s=arc-20160816; b=0BlnSg7MNmqWrLPWuPgu0rLqu9iTT2wlsOXZBLcQyo5HW9lyW+Xx1/zv0Bxn4Pnv6V ULVoKUCeX6uhpQPlMS8Wn/6PToKSlx1F7u5asWhs8qvhk+KU5IFpee8dBkmSUbLB5we1 eB3r+2ZWcqUEDhlRNZrs6TeAwuYE9KORoktRxBiAyHoE3aEA4eqaZFjb4PGhdsrmRIyF 0esx+Jn86DfingB//S6iT6+lYV+aenyiG8RK3vAzu5yldOaxvwVEO0nchToOxWAOPyF1 ixun/cldma6vDU8UPztCygGs16tAKS5ojRW4bdvIr/ZLLFd2Keel9W6iWqIfS438UqJD +vRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=0jotASSVMdaL2J38CEcsYd4kDAo4hxSxaMnLdAHUGkE=; b=U1lKfU2E6iAal3SakvI32cDwx4XwJtdrER50yhdFzlBPiDDgUMHhWV7d1iCGzFJB07 jXHdHUe0H4T0Ce+D3nGEN7YeiQv48g/7giz2pDpjegmOeL6H5UmoGCVFJWRARpzxAVAo Vit9bJSAfTPeZQHmEIF/yhXzQQyA1Wca3xivEBSHXnmofBmfJlRUyoF+l6jbHdeyx8av hKTDUBinQ4tSeDVMfGRfLLf89QU5y3P2I8fXlJJvEN2xJYrLkP/vzqZHZKaZLq9S4WU/ PCWShbkTSlIv/eCPFW4Hsq2RNp4BJC5DDhfYZh8FucTWBf+trlwevEc9zj8DPVjlwDjV h0pg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g10si14655170edu.361.2020.07.07.03.42.15; Tue, 07 Jul 2020 03:42:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728275AbgGGKjv (ORCPT + 99 others); Tue, 7 Jul 2020 06:39:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:42476 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726540AbgGGKju (ORCPT ); Tue, 7 Jul 2020 06:39:50 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 067AXRKf129418; Tue, 7 Jul 2020 06:39:43 -0400 Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 324f7dv0cn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 06:39:42 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 067AYHYF131555; Tue, 7 Jul 2020 06:39:42 -0400 Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com with ESMTP id 324f7dv0ah-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 06:39:40 -0400 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 067AafGE015944; Tue, 7 Jul 2020 10:39:36 GMT Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by ppma02fra.de.ibm.com with ESMTP id 322hd83ckw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 07 Jul 2020 10:39:36 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 067AcIit393544 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 7 Jul 2020 10:38:18 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AC590A405B; Tue, 7 Jul 2020 10:38:18 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D362DA4054; Tue, 7 Jul 2020 10:38:17 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.29.12]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 7 Jul 2020 10:38:17 +0000 (GMT) Subject: Re: [PATCH v4 2/2] s390: virtio: PV needs VIRTIO I/O device protection To: Cornelia Huck Cc: linux-kernel@vger.kernel.org, pasic@linux.ibm.com, borntraeger@de.ibm.com, frankja@linux.ibm.com, mst@redhat.com, jasowang@redhat.com, kvm@vger.kernel.org, linux-s390@vger.kernel.org, virtualization@lists.linux-foundation.org, thomas.lendacky@amd.com, david@gibson.dropbear.id.au, linuxram@us.ibm.com, heiko.carstens@de.ibm.com, gor@linux.ibm.com References: <1594111477-15401-1-git-send-email-pmorel@linux.ibm.com> <1594111477-15401-3-git-send-email-pmorel@linux.ibm.com> <20200707114633.68122a00.cohuck@redhat.com> From: Pierre Morel Message-ID: Date: Tue, 7 Jul 2020 12:38:17 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200707114633.68122a00.cohuck@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-07_06:2020-07-07,2020-07-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 impostorscore=0 bulkscore=0 spamscore=0 clxscore=1015 cotscore=-2147483648 mlxscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007070077 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-07-07 11:46, Cornelia Huck wrote: > On Tue, 7 Jul 2020 10:44:37 +0200 > Pierre Morel wrote: > >> S390, protecting the guest memory against unauthorized host access >> needs to enforce VIRTIO I/O device protection through the use of >> VIRTIO_F_VERSION_1 and VIRTIO_F_IOMMU_PLATFORM. > > Hm... what about: > > "If protected virtualization is active on s390, the virtio queues are > not accessible to the host, unless VIRTIO_F_IOMMU_PLATFORM has been > negotiated. Use the new arch_validate_virtio_features() interface to > enforce this." Yes, thanks. > >> >> Signed-off-by: Pierre Morel >> --- >> arch/s390/kernel/uv.c | 25 +++++++++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> >> diff --git a/arch/s390/kernel/uv.c b/arch/s390/kernel/uv.c >> index c296e5c8dbf9..106330f6eda1 100644 >> --- a/arch/s390/kernel/uv.c >> +++ b/arch/s390/kernel/uv.c >> @@ -14,6 +14,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -413,3 +414,27 @@ static int __init uv_info_init(void) >> } >> device_initcall(uv_info_init); >> #endif >> + >> +/* >> + * arch_validate_virtio_iommu_platform > > s/arch_validate_virtio_iommu_platform/arch_validate_virtio_features/ > >> + * @dev: the VIRTIO device being added >> + * >> + * Return value: returns -ENODEV if any features of the >> + * device breaks the protected virtualization >> + * 0 otherwise. > > I don't think you need to specify the contract here: that belongs to > the definition in the virtio core. What about simply adding a sentence > "Return an error if required features are missing on a guest running > with protected virtualization." ? OK, right. > >> + */ >> +int arch_validate_virtio_features(struct virtio_device *dev) >> +{ > > Maybe jump out immediately if the guest is not protected? > >> + if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { >> + dev_warn(&dev->dev, "device must provide VIRTIO_F_VERSION_1\n"); >> + return is_prot_virt_guest() ? -ENODEV : 0; >> + } >> + >> + if (!virtio_has_feature(dev, VIRTIO_F_IOMMU_PLATFORM)) { >> + dev_warn(&dev->dev, >> + "device must provide VIRTIO_F_IOMMU_PLATFORM\n"); >> + return is_prot_virt_guest() ? -ENODEV : 0; >> + } > > if (!is_prot_virt_guest()) > return 0; > > if (!virtio_has_feature(dev, VIRTIO_F_VERSION_1)) { > dev_warn(&dev->dev, > "legacy virtio is incompatible with protected guests"); > return -ENODEV; > } > > if (!virtio_has_feature(dev, VIRTIO_F_IOMMU_PLATFORM)) { > dev_warn(&dev->dev, > "device does not work with limited memory access in protected guests"); > return -ENODEV; > } Yes, easier to read. Thanks, Pierre -- Pierre Morel IBM Lab Boeblingen