From patchwork Tue Dec 13 16:53:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janis Schoetterl-Glausch X-Patchwork-Id: 32882 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp238396wrn; Tue, 13 Dec 2022 08:55:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf6jBHXDmo9eUrnoQLvaV/jI1M8CkW+9aUILpUw2kBdBT6LYZHJYuXW5yewZhr79PjXU+MAK X-Received: by 2002:a17:90b:803:b0:219:818f:9da3 with SMTP id bk3-20020a17090b080300b00219818f9da3mr21399099pjb.17.1670950544540; Tue, 13 Dec 2022 08:55:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670950544; cv=none; d=google.com; s=arc-20160816; b=lnGySABQ6pYwDh1xmfLzubLGQbNsjhpAKtCcctwsyQEJui3hVRawwteM5bEj7rMREo Y7xONSjRkIbEElysuCRt+ES5VzTQ/nDL70G1rg41kSb53j7cij0pqJ7R+osOLRnCierV R4kEzJrDotaG2f79Xll6qLRauv1rJwAwJnc/YZ/IUoqOxiQHEVGxiGsjmHpeLvwcrAzL t+CiXJ6Df83zniclImmsdfFNb18y+kcFaTAc3YbGeTYUBRIkJUU15dkTXJ6HoIyhQoIL eU9Vf15A2U6NcaGOq0M/oZflJ6Ycb/ifITwWeRFUF/3Hee5RCG4hLbo5BVHyv9+yHWom SbwQ== 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=uiaJuEeysT6tUg7dLYLFfkkEKU2t2cRxBaymDwKx/tE=; b=L5XMP/CSt+CtlSeawEAfNjbYECYzuq9CVHS2vMGF0nCefMXdp87BqkQ/LF1KLBg+05 4OcVFJkhqusxorZ99rw7Pzu0N6xWxVevP1kRa8V/IEOAGsIi4u49VO6/7NvmySh5x6eG 75Rw9L36Ncl6jetafFb3+OmuUfeyCvUFTr8KL2Kkzmt4fefX2xik/klvXcoPiW/+V+oP LSgWLLCSKOQuJxUZgRVrgi9eaLTU8u/DDipkwGdXv7EwdypBa/sM3KTGvgxpaxCWYsSy RiVGeXyc2wezHbMn2jsaEItu1LqSU3tgmm1H9VWaB2TPMvdfEj5JZXvhJSRfOLVWI0WM Y5dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=EeW7wOLO; 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 mj24-20020a17090b369800b002009d750a2dsi12910873pjb.58.2022.12.13.08.55.31; Tue, 13 Dec 2022 08:55:44 -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=EeW7wOLO; 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 S236188AbiLMQyj (ORCPT + 99 others); Tue, 13 Dec 2022 11:54:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235565AbiLMQyZ (ORCPT ); Tue, 13 Dec 2022 11:54:25 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8C0922511; Tue, 13 Dec 2022 08:54:24 -0800 (PST) Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDGiDZb029776; Tue, 13 Dec 2022 16:54:19 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=uiaJuEeysT6tUg7dLYLFfkkEKU2t2cRxBaymDwKx/tE=; b=EeW7wOLOCOB45hakd/IN8e0D+5GipAb4OYdc+CTWqv7SPGuQGwQSUCl8iVXqT3JEuqR6 /Jc/7Xv3qzqmQhwny+ZNvkVGTEeJB0vuSwl01XSoIx8WQnSRsU4ctTMRo7nUvs3UX6mL 7CudX11VL7XWXam5EufRymtcVpkhvVvLK4vF6Th506GZY2GHdeFz4PHC2P7mlzOxbG+Y v3rDV9jMsFRr3wM1cs3iMrwtZWRixv48eE042GxOlf4vO4xBIPjz1H/cb0mPhvyTvQ/z uTvb9RjfOFdE0XfQ2EWR17LQLHFIhgv21P87ZGSxxXXT8HNO482cg07ts/60gMBAh0D+ yA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mew61g8gm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:54:19 +0000 Received: from m0098421.ppops.net (m0098421.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 2BDGirIS000335; Tue, 13 Dec 2022 16:54:19 GMT Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mew61g8fv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:54:18 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2BDGE5BZ028390; Tue, 13 Dec 2022 16:54:17 GMT Received: from smtprelay06.fra02v.mail.ibm.com ([9.218.2.230]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3mchr64fpc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Dec 2022 16:54:17 +0000 Received: from smtpav07.fra02v.mail.ibm.com (smtpav07.fra02v.mail.ibm.com [10.20.54.106]) by smtprelay06.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2BDGsDtE23724554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Dec 2022 16:54:13 GMT Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 68A1B20040; Tue, 13 Dec 2022 16:54:13 +0000 (GMT) Received: from smtpav07.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3186220049; Tue, 13 Dec 2022 16:54:13 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav07.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 13 Dec 2022 16:54:13 +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 v4 2/9] Documentation: KVM: s390: Describe KVM_S390_MEMOP_F_CMPXCHG Date: Tue, 13 Dec 2022 17:53:58 +0100 Message-Id: <20221213165405.2953539-3-scgl@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221213165405.2953539-1-scgl@linux.ibm.com> References: <20221213165405.2953539-1-scgl@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: y9rxpg2hT1ShmnreNGnXJrQYIpgnpjfH X-Proofpoint-ORIG-GUID: cdDGzcxPwSWI3eZo6yhfs8WiqVY4i8D5 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=2022-12-13_03,2022-12-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1011 impostorscore=0 suspectscore=0 adultscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 priorityscore=1501 mlxlogscore=681 mlxscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212130147 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752118638147160677?= X-GMAIL-MSGID: =?utf-8?q?1752118638147160677?= 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 eee9f857a986..98f5a35088b8 100644 --- a/Documentation/virt/kvm/api.rst +++ b/Documentation/virt/kvm/api.rst @@ -3753,7 +3753,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 @@ -3771,6 +3772,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 */ @@ -3853,8 +3856,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: ^^^^^^^^^^^^^^^^