Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp391978pxv; Thu, 15 Jul 2021 06:44:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxH0Bh4TrhaFDKlWiqZs3YScocwSkjJlhs88uRO5CKrOkymLTBJ/fX8rsvpca5Mvy4NEvNC X-Received: by 2002:a17:906:1156:: with SMTP id i22mr5839115eja.167.1626356660569; Thu, 15 Jul 2021 06:44:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626356660; cv=none; d=google.com; s=arc-20160816; b=lVZcYny5fLXCIMBk8jz9bmBd2KMReHjI4wZLZpNFSzJyt/Ht1Y4/V9BZaeCA4QEBFN wjZHj54tpCeQgYctkoQ/vWR5EydkVMMn1ayxskDJK0/6fs0v6a0IBKPC9jL4XnHA2FRS 9oXOPjFTkV49YZwp83ohqwFUhBww2bMjz3ROEHHYBvfolyNwZ//Wxa41td8XKRWz5+7U tq8Gskfkfmdff9OGja4RgxpX3TBr71UjdjinZtOHxJyE7kcTlqCIpuyOttFLego2hPuL Xsgi1cBd5guiouc54f93oAouvRgAy1xcT0EC/E5MVEFw24QhvPCUIqXZH3+tpLM01Alx ZONg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=CNbe1og/tc+798JHBvXCBvhqALKUF9irU9Aw/lDGGBk=; b=qvFfZArlR+fLomZU8feQR1EuqCML/bOS5JxKZUun2JwYlD+Kl1P8WwLEj3NJAGTQzV PI+sBq9yNr3QD/n3rzmPzQImt1xTmGBgHrAYomAJVU4LtuB+pMYAGy7x/5S5N8bRu3S1 v7eVLUjmWqm80AD7HoN89JF9xINQkV98CqAXUVEFU2Q5StuOvTU9Ut6vRko7o+Y4gelV cKG4pSIPkmwGIncFZP/XP4rL4KTuhIkfxFyCsnQ9obYeA+g8r4YsW4l2wyg3OVYx8Egk w316rqpLKlBLhYjNARmCGseroR4OuS2peaQHBHMBlD6af0LpH1Chp74+i74tSKo3vv4j Haug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R+lgGK2h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs37si7935216ejc.263.2021.07.15.06.43.57; Thu, 15 Jul 2021 06:44:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R+lgGK2h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S240976AbhGOKEw (ORCPT + 99 others); Thu, 15 Jul 2021 06:04:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24404 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232043AbhGOKEv (ORCPT ); Thu, 15 Jul 2021 06:04:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626343318; 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=CNbe1og/tc+798JHBvXCBvhqALKUF9irU9Aw/lDGGBk=; b=R+lgGK2hNIGDm7n4hY+1x0Tx0emNcSBFT+4YmI/3I0+noy7Eut2fCV6C9yh7TyFIm75yPK OQHV3v+GBpD6iRmQxWnzuwySeuKeea53wsvfQICnoy+Y0kOwftNooRPbXBVZKYllaNusXW /JVVaBA3PY48u6NN1upWcdKS4tJmKIs= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-587-ZTEcBDOzPO2rT04G3y3Q4Q-1; Thu, 15 Jul 2021 06:01:57 -0400 X-MC-Unique: ZTEcBDOzPO2rT04G3y3Q4Q-1 Received: by mail-wr1-f69.google.com with SMTP id a4-20020a0560001884b02901401e436a18so3071947wri.21 for ; Thu, 15 Jul 2021 03:01:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=CNbe1og/tc+798JHBvXCBvhqALKUF9irU9Aw/lDGGBk=; b=RGcCnR6EYLxzyjKTIKEkT/zR7GceJV/tCI7vT7oluS9WvwHsZFwvqEOxROJYj90Iv1 hsuV9Ap/fiV2J2urCEHMA3g5kSaHaAKuQKVbH305TmrUPZChKsYvZiT/jSTyXvejia2g uZ7K0jdLAS02EbM3ioymLPEf82UjfjUt3LRCrSMmNF5yJpXBTHmioPaK1sW3Js+pq0gA TTSDrXCBywuCsBbKcbkDBEd608D9PwZ8QzSov7C+DCmGMx1zhLO86Yw7UP4ad0wTZs+6 ckhEFJKFofykvqQMGN16RVq019WcGhjRqzm491ednZ7Bd/lgTE56eZv41uoYwb9Ln1VA 3anA== X-Gm-Message-State: AOAM531bexoiqZWBidik8UHO+88VJtki8wcUFq5m5wCnhsnVRFXD2I2Y VuSJUsEcpqTpnq3YD1uaJ/cB5uuuYNobzV7RZn/QkWj4LsyedHKhs932sDnsnwP0LbgPKBWvWbb joqYqUrv6Uvb26+N0TSmeTceI X-Received: by 2002:adf:f907:: with SMTP id b7mr4420259wrr.357.1626343314022; Thu, 15 Jul 2021 03:01:54 -0700 (PDT) X-Received: by 2002:adf:f907:: with SMTP id b7mr4420139wrr.357.1626343312969; Thu, 15 Jul 2021 03:01:52 -0700 (PDT) Received: from [192.168.3.132] (p4ff23bb3.dip0.t-ipconnect.de. [79.242.59.179]) by smtp.gmail.com with ESMTPSA id l20sm4956850wmq.3.2021.07.15.03.01.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 15 Jul 2021 03:01:52 -0700 (PDT) Subject: Re: [PATCH v1 1/2] s390x: KVM: accept STSI for CPU topology information To: Cornelia Huck , Pierre Morel , kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, borntraeger@de.ibm.com, frankja@linux.ibm.com, thuth@redhat.com, imbrenda@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com References: <1626276343-22805-1-git-send-email-pmorel@linux.ibm.com> <1626276343-22805-2-git-send-email-pmorel@linux.ibm.com> <87fswfdiuu.fsf@redhat.com> From: David Hildenbrand Organization: Red Hat Message-ID: <57e57ba5-62ea-f1ff-0d83-5605d57be92d@redhat.com> Date: Thu, 15 Jul 2021 12:01:51 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87fswfdiuu.fsf@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 15.07.21 11:30, Cornelia Huck wrote: > On Thu, Jul 15 2021, David Hildenbrand wrote: > >> On 14.07.21 17:25, Pierre Morel wrote: >>> STSI(15.1.x) gives information on the CPU configuration topology. >>> Let's accept the interception of STSI with the function code 15 and >>> let the userland part of the hypervisor handle it. >>> >>> Signed-off-by: Pierre Morel >>> --- >>> arch/s390/kvm/priv.c | 11 ++++++++++- >>> 1 file changed, 10 insertions(+), 1 deletion(-) >>> >>> diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c >>> index 9928f785c677..4ab5f8b7780e 100644 >>> --- a/arch/s390/kvm/priv.c >>> +++ b/arch/s390/kvm/priv.c >>> @@ -856,7 +856,7 @@ static int handle_stsi(struct kvm_vcpu *vcpu) >>> if (vcpu->arch.sie_block->gpsw.mask & PSW_MASK_PSTATE) >>> return kvm_s390_inject_program_int(vcpu, PGM_PRIVILEGED_OP); >>> >>> - if (fc > 3) { >>> + if (fc > 3 && fc != 15) { >>> kvm_s390_set_psw_cc(vcpu, 3); >>> return 0; >>> } >>> @@ -893,6 +893,15 @@ static int handle_stsi(struct kvm_vcpu *vcpu) >>> goto out_no_data; >>> handle_stsi_3_2_2(vcpu, (void *) mem); >>> break; >>> + case 15: >>> + if (sel1 != 1 || sel2 < 2 || sel2 > 6) >>> + goto out_no_data; >>> + if (vcpu->kvm->arch.user_stsi) { >>> + insert_stsi_usr_data(vcpu, operand2, ar, fc, sel1, sel2); >>> + return -EREMOTE; > > This bypasses the trace event further down. > >>> + } >>> + kvm_s390_set_psw_cc(vcpu, 3); >>> + return 0; >>> } >>> if (kvm_s390_pv_cpu_is_protected(vcpu)) { >>> memcpy((void *)sida_origin(vcpu->arch.sie_block), (void *)mem, >>> >> >> 1. Setting GPRS to 0 >> >> I was wondering why we have the "vcpu->run->s.regs.gprs[0] = 0;" >> for existing fc 1,2,3 in case we set cc=0. >> >> Looking at the doc, all I find is: >> >> "CC 0: Requested configuration-level number placed in >> general register 0 or requested SYSIB informa- >> tion stored" >> >> But I don't find where it states that we are supposed to set >> general register 0 to 0. Wouldn't we also have to do it for >> fc=15 or for none? >> >> If fc 1,2,3 and 15 are to be handled equally, I suggest the following: >> >> diff --git a/arch/s390/kvm/priv.c b/arch/s390/kvm/priv.c >> index 9928f785c677..6eb86fa58b0b 100644 >> --- a/arch/s390/kvm/priv.c >> +++ b/arch/s390/kvm/priv.c >> @@ -893,17 +893,23 @@ static int handle_stsi(struct kvm_vcpu *vcpu) >> goto out_no_data; >> handle_stsi_3_2_2(vcpu, (void *) mem); >> break; >> + case 15: >> + if (sel1 != 1 || sel2 < 2 || sel2 > 6) >> + goto out_no_data; >> + break; >> } >> - if (kvm_s390_pv_cpu_is_protected(vcpu)) { >> - memcpy((void *)sida_origin(vcpu->arch.sie_block), (void *)mem, >> - PAGE_SIZE); >> - rc = 0; >> - } else { >> - rc = write_guest(vcpu, operand2, ar, (void *)mem, PAGE_SIZE); >> - } >> - if (rc) { >> - rc = kvm_s390_inject_prog_cond(vcpu, rc); >> - goto out; >> + if (mem) { >> + if (kvm_s390_pv_cpu_is_protected(vcpu)) { >> + memcpy((void *)sida_origin(vcpu->arch.sie_block), >> + (void *)mem, PAGE_SIZE); >> + } else { >> + rc = write_guest(vcpu, operand2, ar, (void *)mem, >> + PAGE_SIZE); >> + if (rc) { >> + rc = kvm_s390_inject_prog_cond(vcpu, rc); >> + goto out; >> + } >> + } >> } >> if (vcpu->kvm->arch.user_stsi) { >> insert_stsi_usr_data(vcpu, operand2, ar, fc, sel1, sel2); > > Something like that sounds good, the code is getting a bit convoluted. > >> >> >> 2. maximum-MNest facility >> >> " >> 1. If the maximum-MNest facility is installed and >> selector 2 exceeds the nonzero model-depen- >> dent maximum-selector-2 value." >> >> 2. If the maximum-MNest facility is not installed and >> selector 2 is not specified as two. >> " >> >> We will we be handling the presence/absence of the maximum-MNest facility >> (for our guest?) in QEMU, corect? >> >> I do wonder if we should just let any fc=15 go to user space let the whole >> sel1 / sel2 checking be handled there. I don't think it's a fast path after all. >> But no strong opinion. > > If that makes handling easier, I think it would be a good idea. > >> >> How do we identify availability of maximum-MNest facility? >> >> >> 3. User space awareness >> >> How can user space identify that we actually forward these intercepts? >> How can it enable them? The old KVM_CAP_S390_USER_STSI capability >> is not sufficient. > > Why do you think that it is not sufficient? USER_STSI basically says > "you may get an exit that tells you about a buffer to fill in some more > data for a stsi command, and we also tell you which call". If userspace > does not know what to add for a certain call, it is free to just do > nothing, and if it does not get some calls it would support, that should > not be a problem, either? If you migrate your VM from machine a to machine b, from kernel a to kernel b, and kernel b does not trigger exits to user space for fc=15, how could QEMU spot and catch the different capabilities to make sure the guest can continue using the feature? -- Thanks, David / dhildenb