Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp672331rwb; Fri, 18 Nov 2022 06:53:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf5k6xr1MoFusOcNuVNMeZKmO332PFPXFStzPeKAQ7QX70Zozr6RICIKTbH3pua5Chxk3VGr X-Received: by 2002:a17:902:9f8f:b0:186:738e:5703 with SMTP id g15-20020a1709029f8f00b00186738e5703mr7798720plq.136.1668783194267; Fri, 18 Nov 2022 06:53:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668783194; cv=none; d=google.com; s=arc-20160816; b=Gl6N6kOP2+FJL70pPvUeMMct9As8M40mGVlBLlbd606s3m+hGy3Gi2b2DNFvKcAPwZ uvicSOtnjByxILd8ZCn03ryDOwf28LON7SzBnzU5qfPagKi30Bcb1rYPAR8Y4xANYILm jEMYljI7NdLQJGnZ1YMq5fCWcV4dGO2+9Qq46SQnKNDh4FBhBTkTOYfmQ9fIVJVSLMWe OxEhDR0lEW4ZnBDNGlSc0FKuXXcVGdNP6kNL0ejCuyMvykZrACi057cvKIKFRd7w+WCj GGHJO15OksQlDYEkNsEyP+BrFno4R60DaaYwT8e3xQ2+438VZi75kvseud+ntYsjr8cQ 8S1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=UPk972akfZfuwBephZFAJS92+OaEvfxCgvAwmUwC+Mw=; b=PNfgzipf3Y5+LgDqyn2H37brxpRHolUyoxke35P228K958W+kK8MYSaG30YwsIzVYh 46t/nMS892DBO7kNfUAU5ALeOxzvSf6epQaxiguVmAOcf6cQPLeUfQhLmi2NMczQUSUl TKvj8v77yoIISFFTu6dOb2oLQOZ+NW9TC9TUumL/kg7CTNdficQL0wk+fh1FZkbY5Ko4 V8UpiWQ+mPoMII8O8z8XyAI7Mg2u1ZNGvUg/31RCPlhtejWxsyJm2KGl1QjHI45U8iOW 9l6Pe//w0kCmqYJpC572CYtVSmDw8azcknpmCgQJBBrhCE1vjCAxbQITVBADpeg5ZiIB oBRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YUtvkGSg; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cm9-20020a056a00338900b0056be3109462si3605702pfb.163.2022.11.18.06.52.52; Fri, 18 Nov 2022 06:53:14 -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=@redhat.com header.s=mimecast20190719 header.b=YUtvkGSg; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242127AbiKROlu (ORCPT + 91 others); Fri, 18 Nov 2022 09:41:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241807AbiKROlW (ORCPT ); Fri, 18 Nov 2022 09:41:22 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4E67970B9 for ; Fri, 18 Nov 2022 06:37:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668782250; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UPk972akfZfuwBephZFAJS92+OaEvfxCgvAwmUwC+Mw=; b=YUtvkGSgPPfgA7l0qfbnCJ9GvL5fr/n+069bmlGWeMryG2A2RBNICl2IdYqxE1SyuoiiQ1 KltbpZiq6E2tmipxCagAbNmWkTRN54N4ulxCGZfN1A5VBBxErnOwdXlQ4+NuRWZ8CTD/cH z1eP+kaj+iZMeRkcfYFjv5zrmV4DWfs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-62-aYeUJXPdMTOXbb-nw9B3TQ-1; Fri, 18 Nov 2022 09:37:29 -0500 X-MC-Unique: aYeUJXPdMTOXbb-nw9B3TQ-1 Received: by mail-wm1-f70.google.com with SMTP id h188-20020a1c21c5000000b003cfe4cc64eeso4546826wmh.6 for ; Fri, 18 Nov 2022 06:37:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=UPk972akfZfuwBephZFAJS92+OaEvfxCgvAwmUwC+Mw=; b=eRzmbcAy1o0dbqDaTZhalQ6G6ikPwSudCIm26xVBBr90aFci28QNNnkgaHdTTgFwmF J31khnKwmuISkWbTKdku4+5eiV8uVGzb14uJAGP4TR+BLYqPkk0SLto9hwBp/GDsAhAa XP4zPpeJQt1OefGhp27EHHLSamZMXDEy2SAUxbxmdKDJZs2mr8OU9HbBk+qXTRvX2VB+ /hzMLBPyJsFc7cgvMC3MX/rChfzV5iHHRazyjDoBaPPGgAR9ngTa7jVOrOGVcWJTbrZY GYeJtwBy8GlMgyMY5FBHQXXMlHj3XwmpFI5CqwS8NKtJ9W8spbKjCvLHdsSz+EhAHebs ZCew== X-Gm-Message-State: ANoB5pnRr4YklHZJZ0kfpOSoInLPJ5HCKKgaa66t3MuwYG04w06Et3qP DFToyib1RrQahSDRleffYdF1w2TkPKACkQmkdw+/eLlGHxLD3nPdSfGIKyGS6FQmYxMwCe5bgNT e4YUOWUVPeWsOqEzZjYWamrLr X-Received: by 2002:a5d:4c8c:0:b0:241:c222:e27e with SMTP id z12-20020a5d4c8c000000b00241c222e27emr357994wrs.236.1668782248584; Fri, 18 Nov 2022 06:37:28 -0800 (PST) X-Received: by 2002:a5d:4c8c:0:b0:241:c222:e27e with SMTP id z12-20020a5d4c8c000000b00241c222e27emr357982wrs.236.1668782248374; Fri, 18 Nov 2022 06:37:28 -0800 (PST) Received: from [192.168.0.5] (ip-109-43-177-78.web.vodafone.de. [109.43.177.78]) by smtp.gmail.com with ESMTPSA id he5-20020a05600c540500b003cfd4e6400csm4824578wmb.19.2022.11.18.06.37.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Nov 2022 06:37:27 -0800 (PST) Message-ID: <90f07edc-238f-b3d0-80d2-f4b4573f12ad@redhat.com> Date: Fri, 18 Nov 2022 15:37:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH v3 1/9] KVM: s390: Extend MEM_OP ioctl by storage key checked cmpxchg Content-Language: en-US To: Heiko Carstens , Janis Schoetterl-Glausch Cc: Christian Borntraeger , Janosch Frank , Claudio Imbrenda , 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 References: <20221117221758.66326-1-scgl@linux.ibm.com> <20221117221758.66326-2-scgl@linux.ibm.com> From: Thomas Huth In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 18/11/2022 11.12, Heiko Carstens wrote: > On Thu, Nov 17, 2022 at 11:17:50PM +0100, Janis Schoetterl-Glausch wrote: >> User space can use the MEM_OP ioctl to make storage key checked reads >> and writes to the guest, however, it has no way of performing atomic, >> key checked, accesses to the guest. >> Extend the MEM_OP ioctl in order to allow for this, by adding a cmpxchg >> mode. For now, support this mode for absolute accesses only. >> >> This mode can be use, for example, to set the device-state-change >> indicator and the adapter-local-summary indicator atomically. >> >> Signed-off-by: Janis Schoetterl-Glausch >> --- >> include/uapi/linux/kvm.h | 5 ++ >> arch/s390/kvm/gaccess.h | 3 ++ >> arch/s390/kvm/gaccess.c | 101 +++++++++++++++++++++++++++++++++++++++ >> arch/s390/kvm/kvm-s390.c | 35 +++++++++++++- >> 4 files changed, 142 insertions(+), 2 deletions(-) >> >> diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h >> index 0d5d4419139a..1f36be5493e6 100644 >> --- a/include/uapi/linux/kvm.h >> +++ b/include/uapi/linux/kvm.h >> @@ -588,6 +588,8 @@ struct kvm_s390_mem_op { >> struct { >> __u8 ar; /* the access register number */ >> __u8 key; /* access key, ignored if flag unset */ >> + __u8 pad1[6]; /* ignored */ >> + __u64 old_p; /* ignored if flag unset */ > > Just one comment: the suffix "_p" for pointer is quite unusual within > the kernel. This also would be the first of its kind within kvm.h. > Usually there is either no suffix or "_addr". > So for consistency reasons I would suggest to change this to one of > the common variants. > > The code itself looks good from my point of view, even though for the > sake of simplicity I would have put the complete sign/zero extended > 128 bit old value into the structure, instead of having a pointer to > the value. See https://lore.kernel.org/kvm/37197cfe-d109-332f-089b-266d7e8e23f8@redhat.com/ ... it would break the "IOW" definition of the ioctl. It can be done, but that confuses tools like valgrind, as far as I know. So I think the idea with the pointer is better in this case. Thomas