Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1823289rwb; Fri, 2 Dec 2022 01:24:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Kx9x0X1FFEgmhRNrcHggkCJsstlyl1OBJjnhsUvgWTaG9D/chXqwi4BCCpZklnndHTxu/ X-Received: by 2002:a62:b501:0:b0:573:1959:c356 with SMTP id y1-20020a62b501000000b005731959c356mr51902968pfe.51.1669973044127; Fri, 02 Dec 2022 01:24:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669973044; cv=none; d=google.com; s=arc-20160816; b=vLSGFV9h4BmmLyScEMWi1799z51NCYJm5U3ZuExYFvLRiFrxf/58R2yTmfRdWw09Qm W2ipUmjp8YVpbltN1tAszsHOiMbcPVN0GAEzy18SupCO08jxtxctl5HKccwmp0H8huR8 XteBRnTMhSiXQgP0VXWQgYKU/T/9Yjb2iRDFw1nw2LmOCN+H2oB71XsYwnoly0nEYcLy xXlMSUV2JG6H/K9yUmic9YqONOstfZNCJXlnZTvKiFH+gfrptv2abECp/jDbkcC3NL20 hSHHQffqUq3tCDJrUqAIm04fQEBq7zjmvFe0gRN1gddnh2RldNxJC4+OAU6xXQZ77slw IG+w== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=8xnE/Mb0rP1cjkQQ7k3iLfRpCly+KU3D84URS1QVylo=; b=oVm8dqsp58gsB7+yTGbEtnNXqegXgv0CFey3LPHGg1U7H57tNKpNpYITp1TNbAI8nb TdHkSB89nKB5wLuQ30MC3U2dviXvZGn2m3v4qsWtrxdCZbTQ/k8vZ1mQXqhKJwff1qKq V6b4ncPS2VXzXBrEXjlz55AMUOQO/Rmv0tgNWQUD+eEjeIznlSfcp546NF3HHTLzbORp RlO2dfpfTS9jyxJZo3k8NfHMdBxwQulpu+Qa54exWOixc8LGud9gUDeWD9tBEU97rC4D +yVi2CmXZJxT9RWrdDu6QDFipCfJE6ujNiHtZxry0CFCqpJODgWTAfDjXpvDKvo/AgFE y/Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="Ua5V/Efa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n7-20020a170903110700b00186abd0c784si7876364plh.217.2022.12.02.01.23.53; Fri, 02 Dec 2022 01:24:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="Ua5V/Efa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232736AbiLBJC6 (ORCPT + 83 others); Fri, 2 Dec 2022 04:02:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232294AbiLBJCT (ORCPT ); Fri, 2 Dec 2022 04:02:19 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC7798547; Fri, 2 Dec 2022 01:00:42 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B27g5ts013292; Fri, 2 Dec 2022 09:00:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=date : from : to : cc : subject : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=pp1; bh=8xnE/Mb0rP1cjkQQ7k3iLfRpCly+KU3D84URS1QVylo=; b=Ua5V/Efa2ZJwhDOyOgGdP3pTKIK0thms7qhlRfn0gaKcR0oon45fGCPDuCVrs7wJ9iAp sCNnrdEUNqOm/Q2Rm5R6uR1kGUuWCKfCJFkMNfAEldVZB/fshpHAYTJ97TkVn+guABZZ RB+SibMAVqVXZe1tOfMs3gNWQ/imiZ8tNStiAaqu5gxShzFWDn5sWA0COYb9iUQB0XES Pt1BcOjBp7K+LpsIJp1g92kvCpvClFzKZ0Yr4npvr0rvOD3EWoInrGrAiZarOpeyfX2k mu4XnnDjLoTD3frZbpHvO9fstRvh9foLMKFkBoCz7Q7pnDr4DtHEKdDoWI4qEGBYgbSv jA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m7d6t1w9h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 09:00:39 +0000 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2B28UEkL016043; Fri, 2 Dec 2022 09:00:38 GMT Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3m7d6t1w88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 09:00:38 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 2B28njd3006167; Fri, 2 Dec 2022 09:00:36 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma04ams.nl.ibm.com with ESMTP id 3m3ae9gtk7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Dec 2022 09:00:36 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B291GEY4195004 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 2 Dec 2022 09:01:16 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0F344A4055; Fri, 2 Dec 2022 09:00:33 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7D90DA4040; Fri, 2 Dec 2022 09:00:31 +0000 (GMT) Received: from p-imbrenda (unknown [9.171.31.115]) by d06av23.portsmouth.uk.ibm.com (Postfix) with SMTP; Fri, 2 Dec 2022 09:00:31 +0000 (GMT) Date: Fri, 2 Dec 2022 10:00:28 +0100 From: Claudio Imbrenda To: Janis Schoetterl-Glausch Cc: Christian Borntraeger , Janosch Frank , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , David Hildenbrand , Jonathan Corbet , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-s390@vger.kernel.org, Paolo Bonzini , Shuah Khan , Sven Schnelle Subject: Re: [PATCH v3 1/9] KVM: s390: Extend MEM_OP ioctl by storage key checked cmpxchg Message-ID: <20221202100028.686c605e@p-imbrenda> In-Reply-To: References: <20221117221758.66326-1-scgl@linux.ibm.com> <20221117221758.66326-2-scgl@linux.ibm.com> <20221201171528.13f17ec4@p-imbrenda> Organization: IBM X-Mailer: Claws Mail 4.1.1 (GTK 3.24.35; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: MIE7Tkq8dREDb3bLyBCIWdFsFhwuZl_T X-Proofpoint-ORIG-GUID: echR8s-Y313utW3Umn7s9LGDwFrdS-el X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-02_04,2022-12-01_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 adultscore=0 spamscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 clxscore=1015 impostorscore=0 lowpriorityscore=0 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212020065 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 01 Dec 2022 18:44:56 +0100 Janis Schoetterl-Glausch wrote: > > > > please also document -EOPNOTSUPP > > I'd add "* -EOPNOTSUPP: should never occur", then, that ok with you? no, also explain in which conditions it is returned something like: * -EOPNOTSUPP: if the memslot is not writable (should never occour) > > > > > + */ > > > +int cmpxchg_guest_abs_with_key(struct kvm *kvm, gpa_t gpa, int len, > > > + __uint128_t *old_p, __uint128_t new, > > > + u8 access_key) > > > +{ > > > + gfn_t gfn = gpa >> PAGE_SHIFT; > > > + struct kvm_memory_slot *slot = gfn_to_memslot(kvm, gfn); > > > > exchange the above two lines (reverse christmas tree) > > Is this a hard requirement? Since there is a dependency. > If I do the initialization further down, the order wouldn't actually change. ahhhhh right, I had missed that keep it as it is, of course [...] > > I really dislike repeating the same code 5 times, but I guess there was > > no other way? > > I could use the function called by cmpxchg_user_key directly, but Heiko won't agree to that. > A macro would work too, of course, not sure if I prefer that tho. ok so there is no other way, let's keep it as it is [...] > To me it feels like KVM_S390_MEMOP_R_NO_XCHG is api surface and should be referenced here. > cmpxchg_guest_abs_with_key isn't mem op specific > (of course that's the only thing it is currently used for). fair enough > > > > > + if (copy_to_user(old_p, &old.raw[off_in_quad], mop->size)) > > > + r = -EFAULT; > > > + } > > > } else { > > > if (copy_from_user(tmpbuf, uaddr, mop->size)) { > > > r = -EFAULT; > > >