Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp8696544rwb; Tue, 13 Dec 2022 09:19:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf7LmCidzi7Drs4pgagcMNuXCNk6zXE+JUw39QxhCA46OexAa8RmrzCGm0kaUZ+jd3wF2EjP X-Received: by 2002:a05:6a21:8dcc:b0:ac:29b7:54dc with SMTP id ti12-20020a056a218dcc00b000ac29b754dcmr20808605pzb.5.1670951990306; Tue, 13 Dec 2022 09:19:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670951990; cv=none; d=google.com; s=arc-20160816; b=OrnX7LFsxdOOZba+T3X6HuBxAICcXwXmeqkjcuSN9okJkgYfb1JqWI043cNif6DV/x ilRrUwXVCO2yWXyRGj21ZIINAU+do+dH1ts/dLoPhbeqdQMD5n3UiqoBBWhyqy2ljR82 ubeQj394XPJtJgLsfFnVYTC67ZPxrYp9u5dV5PzefH/6CCEvJPtyAmby+YzfnOtU5Eqc uqh8Qq1TKYMAxHbLpCNj3D6R6kRMBEHOQKROi0Fxb9bhEzeVFK4IovaAMQNGaxCenunY s1joxJ/aOPlbxMJqd6Yx4IZbrj32wTKniyM003V9iHsNYAFzFPbx3m1dMLkGD8UQ+sZ9 peCQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d10-20020a63fd0a000000b00478dfd40ef6si12862585pgh.768.2022.12.13.09.19.38; Tue, 13 Dec 2022 09:19:50 -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 + 72 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 Content-Transfer-Encoding: 8bit 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 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 --- 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: ^^^^^^^^^^^^^^^^ -- 2.34.1