From patchwork Tue Jan 10 20:26:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janis Schoetterl-Glausch X-Patchwork-Id: 41644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2955361wrt; Tue, 10 Jan 2023 12:30:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXubrMYKuAWm2HCRICd7Zx6xnmX2ceqXJXOR2FQNRd0rOOSzOBYV8hPZWgtyC7lUgsIwpzfz X-Received: by 2002:a17:906:78c:b0:7ad:e52c:12e6 with SMTP id l12-20020a170906078c00b007ade52c12e6mr60096940ejc.41.1673382649938; Tue, 10 Jan 2023 12:30:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673382649; cv=none; d=google.com; s=arc-20160816; b=0jravUXBkEhbsmHudUawqiBeg2MfFTcMtKb0/ipE3KwRTEGEtRrEAoBSsA+DDQt7Fz R6/lgcY1ER2AlJ5s9hTqJxOcmtOnM5moui3xZfgLnw4Yqx2uT3bx4P7vnbZqnBpYWhtX H87vP9qAHTTfJpYnKMiOnAK+buY7mBVMKajZMEIM4qTYPXf6+S2AGSKo9NrErtUvg7GH UQgj+1lgxzgrO4mOclaeEPrShBjwQfx26pUWPeFJ9wOdpzs/RO5V7CH4NvenhG1k7MXv NL5bLgKje/fPEmeb1RSGdubYwbSNIP6TY+Bm8HB+OXwijmSpKEqOfT9stFaIvNDZeXx4 i3vA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8liyfggqVRfKBzRLk22EzT2PLjSMXTAQJY6H3C1Gw0U=; b=NgIOpIdzL59apGcHm7LLmUBu5L6plvTyLPg2s9F7k6Lrxm09vMsxeQqp51YqXnwHb0 LiMFq6Jd7ruHD6uHbcgIaqCMRn6quYmwHN8EIBAR68iNFOQtly2Em9hd3Un1qixuFQpc yzvLf8DK72u5mIckZsyxDXRyqrGoJLcWe+NWWQcsPoMjpL9dX+DW82S0dAkHqVDDK8oA c6dKohBUc3w9rNtGIC6j11DUQg3LxyQlZd5kLtfuAWB1Kx7spyfQYEHf2DCWtf4ClTO4 9cBw7isDuuv18TmVxalGzKwbzPZj7lhu8dH6upODOtpTyBp5+eKaUBlWH0w/iS5a8wHm f2cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=r4xSrecC; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr5-20020a170907720500b008327270a7ffsi12983990ejc.663.2023.01.10.12.30.24; Tue, 10 Jan 2023 12:30:49 -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=r4xSrecC; 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 S233979AbjAJU12 (ORCPT + 99 others); Tue, 10 Jan 2023 15:27:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233391AbjAJU0t (ORCPT ); Tue, 10 Jan 2023 15:26:49 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C1E550E72; Tue, 10 Jan 2023 12:26:46 -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 30AJw0PD008615; Tue, 10 Jan 2023 20:26:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=8liyfggqVRfKBzRLk22EzT2PLjSMXTAQJY6H3C1Gw0U=; b=r4xSrecCGJnH65B1VnW9UAILz1Xn297F2lQ3NDJeeXRBW3hpCoDep1xrIqsN4BVogMEf UL5KQo8toHAQI1ArrKhxVIizLcTdKzaq219hJ88dd5BAYLGu2he9amV+Fnn8cu+XN5k+ exOLLTeZO3CKBCjpitOUclXvzXqAyt69OuIXNH0TSkuyzUIs/qOf5n6HNRHFfUxKRP+l Xsh+eXyIpmARWR4xffOw+aqvDgSB4qYNOpZSXp38XbCShJZpcMxtkvbHfsv7/t4i8yS4 lxTRXD5VzcRHYFACJKVOjgUSrr6hxWr+RwW53x+XewPAOEZAPDVEqsEF7MXP/OWgRzCL og== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n1en0gme0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 20:26:43 +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 30AJwHXt009701; Tue, 10 Jan 2023 20:26:43 GMT Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3n1en0gmdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 20:26:42 +0000 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 30ADAnwL032122; Tue, 10 Jan 2023 20:26:40 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06fra.de.ibm.com (PPS) with ESMTPS id 3my00fkwhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 10 Jan 2023 20:26:40 +0000 Received: from smtpav02.fra02v.mail.ibm.com (smtpav02.fra02v.mail.ibm.com [10.20.54.101]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 30AKQaVF43057534 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 10 Jan 2023 20:26:36 GMT Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6FE720040; Tue, 10 Jan 2023 20:26:36 +0000 (GMT) Received: from smtpav02.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B1B420043; Tue, 10 Jan 2023 20:26:36 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav02.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 10 Jan 2023 20:26:36 +0000 (GMT) From: Janis Schoetterl-Glausch To: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , Heiko Carstens , Vasily Gorbik , Alexander Gordeev Cc: Janis Schoetterl-Glausch , 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: [PATCH v5 02/10] Documentation: KVM: s390: Describe KVM_S390_MEMOP_F_CMPXCHG Date: Tue, 10 Jan 2023 21:26:24 +0100 Message-Id: <20230110202632.2533978-3-scgl@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230110202632.2533978-1-scgl@linux.ibm.com> References: <20230110202632.2533978-1-scgl@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: L1pbXIfoYpoxZX22CZVv5hYB4vhNLsQy X-Proofpoint-GUID: HGmABwWXbw0iEBm20cGtPkBzZkr78Nuv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-10_09,2023-01-10_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 phishscore=0 impostorscore=0 mlxscore=0 mlxlogscore=822 spamscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301100133 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754668885773342434?= X-GMAIL-MSGID: =?utf-8?q?1754668885773342434?= Describe the semantics of the new KVM_S390_MEMOP_F_CMPXCHG flag for absolute vm write memops which allows user space to perform (storage key checked) cmpxchg operations on guest memory. Signed-off-by: Janis Schoetterl-Glausch Reviewed-by: Claudio Imbrenda --- Documentation/virt/kvm/api.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/virt/kvm/api.rst b/Documentation/virt/kvm/api.rst index deb494f759ed..be4bdcd2d489 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -3728,7 +3728,8 @@ The fields in each entry are defined as follows: :Parameters: struct kvm_s390_mem_op (in) :Returns: = 0 on success, < 0 on generic error (e.g. -EFAULT or -ENOMEM), - > 0 if an exception occurred while walking the page tables + 16 bit program exception code if the access causes such an exception, + other code > 0xffff with special meaning. Read or write data from/to the VM's memory. The KVM_CAP_S390_MEM_OP_EXTENSION capability specifies what functionality is @@ -3746,6 +3747,8 @@ Parameters are specified via the following structure:: struct { __u8 ar; /* the access register number */ __u8 key; /* access key, ignored if flag unset */ + __u8 pad1[6]; /* ignored */ + __u64 old_addr; /* ignored if flag unset */ }; __u32 sida_offset; /* offset into the sida */ __u8 reserved[32]; /* ignored */ @@ -3828,8 +3831,21 @@ Absolute accesses are permitted for non-protected guests only. Supported flags: * ``KVM_S390_MEMOP_F_CHECK_ONLY`` * ``KVM_S390_MEMOP_F_SKEY_PROTECTION`` + * ``KVM_S390_MEMOP_F_CMPXCHG`` + +The semantics of the flags common with logical accesses are as for logical +accesses. + +For write accesses, the KVM_S390_MEMOP_F_CMPXCHG flag is supported if +KVM_CAP_S390_MEM_OP_EXTENSION has flag KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG set. +In this case, instead of doing an unconditional write, the access occurs +only if the target location contains the value pointed to by "old_addr". +This is performed as an atomic cmpxchg with the length specified by the "size" +parameter. "size" must be a power of two up to and including 16. +If the exchange did not take place because the target value doesn't match the +old value, KVM_S390_MEMOP_R_NO_XCHG is returned. +In this case the value "old_addr" points to is replaced by the target value. -The semantics of the flags are as for logical accesses. SIDA read/write: ^^^^^^^^^^^^^^^^