From patchwork Fri Jan 22 13:27:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre Morel X-Patchwork-Id: 12039445 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17BC1C433E6 for ; Fri, 22 Jan 2021 13:29:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DCE1323437 for ; Fri, 22 Jan 2021 13:29:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727882AbhAVN3K (ORCPT ); Fri, 22 Jan 2021 08:29:10 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:19292 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727748AbhAVN2q (ORCPT ); Fri, 22 Jan 2021 08:28:46 -0500 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 10MD2NhR156136; Fri, 22 Jan 2021 08:27:48 -0500 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; s=pp1; bh=IyKWwa0SIbFuGT3BagTy9vBpsnez7BJALMQ5s9Sn1Ks=; b=GTDPGgR+P7oMwI6evklvrnYS95tI+vcaT30uQnjXVvAUX9VhBAyjab3eEptac1E6vBiv k1uzXTe6DelGecAXdpLO3/igWtnO+CZSkqdEDOxBYVg3/lUnK0HcfOBb1Tsnym8VoTI1 e33G4R8afjTuFSqrfHcL3N7+wOBEEUHQEd/S2jmF8t15LEj2WT+lxYzhrRs99wGPn4Td Ex6N7z1l4g3R9EnQRTL2x8tgQXGP1ZwxEGHSCZu2BYqnJ+EGfMuj+d0IPm6oEBXeFV2F jswx+tHFsDMp4rEDEFG90kmitkxEk8qLTO9jMah1r2c/+BnhIAjHJblpgSmDyfVVYwnN rA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0b-001b2d01.pphosted.com with ESMTP id 367xgu29ca-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Jan 2021 08:27:48 -0500 Received: from m0098420.ppops.net (m0098420.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 10MD2P5R156345; Fri, 22 Jan 2021 08:27:48 -0500 Received: from ppma06fra.de.ibm.com (48.49.7a9f.ip4.static.sl-reverse.com [159.122.73.72]) by mx0b-001b2d01.pphosted.com with ESMTP id 367xgu29bu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Jan 2021 08:27:48 -0500 Received: from pps.filterd (ppma06fra.de.ibm.com [127.0.0.1]) by ppma06fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 10MDRfFU017570; Fri, 22 Jan 2021 13:27:46 GMT Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by ppma06fra.de.ibm.com with ESMTP id 367k10ra9p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Jan 2021 13:27:46 +0000 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 10MDRhGp46989600 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Jan 2021 13:27:43 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 48110A4057; Fri, 22 Jan 2021 13:27:43 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C7D5FA4040; Fri, 22 Jan 2021 13:27:42 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.82.252]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 22 Jan 2021 13:27:42 +0000 (GMT) From: Pierre Morel To: kvm@vger.kernel.org Cc: linux-s390@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com, thuth@redhat.com, cohuck@redhat.com, imbrenda@linux.ibm.com, drjones@redhat.com, pbonzini@redhat.com Subject: [kvm-unit-tests PATCH v5 1/3] s390x: pv: implement routine to share/unshare memory Date: Fri, 22 Jan 2021 14:27:38 +0100 Message-Id: <1611322060-1972-2-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1611322060-1972-1-git-send-email-pmorel@linux.ibm.com> References: <1611322060-1972-1-git-send-email-pmorel@linux.ibm.com> X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343,18.0.737 definitions=2021-01-22_09:2021-01-21,2021-01-22 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 impostorscore=0 clxscore=1015 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2101220070 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org When communicating with the host we need to share part of the memory. Let's implement the ultravisor calls for this. Signed-off-by: Pierre Morel Suggested-by: Janosch Frank Acked-by: Cornelia Huck Acked-by: Thomas Huth Reviewed-by: Janosch Frank --- lib/s390x/asm/uv.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h index 39d2dc0..9c49184 100644 --- a/lib/s390x/asm/uv.h +++ b/lib/s390x/asm/uv.h @@ -79,4 +79,43 @@ static inline int uv_call(unsigned long r1, unsigned long r2) return cc; } +static inline int share(unsigned long addr, u16 cmd) +{ + struct uv_cb_share uvcb = { + .header.cmd = cmd, + .header.len = sizeof(uvcb), + .paddr = addr + }; + int cc; + + cc = uv_call(0, (u64)&uvcb); + if (!cc && uvcb.header.rc == UVC_RC_EXECUTED) + return 0; + + report_info("uv_call: cmd %04x cc %d response code: %04x", cc, cmd, + uvcb.header.rc); + return -1; +} + +/* + * Guest 2 request to the Ultravisor to make a page shared with the + * hypervisor for IO. + * + * @addr: Real or absolute address of the page to be shared + */ +static inline int uv_set_shared(unsigned long addr) +{ + return share(addr, UVC_CMD_SET_SHARED_ACCESS); +} + +/* + * Guest 2 request to the Ultravisor to make a page unshared. + * + * @addr: Real or absolute address of the page to be unshared + */ +static inline int uv_remove_shared(unsigned long addr) +{ + return share(addr, UVC_CMD_REMOVE_SHARED_ACCESS); +} + #endif