From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,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 A8E6BC4363D for ; Fri, 25 Sep 2020 16:03:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B4B92344C for ; Fri, 25 Sep 2020 16:03:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hrVDpFDi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728524AbgIYQDP (ORCPT ); Fri, 25 Sep 2020 12:03:15 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:23160 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728148AbgIYQDO (ORCPT ); Fri, 25 Sep 2020 12:03:14 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 08PG2xfP061999; Fri, 25 Sep 2020 12:03:14 -0400 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=ZRVzO9kDmoyT7pGzE7Gyiex38XywGmdAlXT+v+oP+Ig=; b=hrVDpFDi8/0ydierxrd8J/ymK25Yv6uCK5v3yQqicHxNqebMklb0QCmMmsov/TIkvpLQ vUNFW8iS7tbFLdESzk+HHddfukHEdLawHNYIoa+rIOdG2H8yp6+Gc/weLlpW+wXLj9+G cCBdbk+r7W3YxtHEbipGmWEFxLIR6ax7rUpAkg576XqFeU0wPTcEzyYX3WD31u72p2F1 k8XCWJz+dCPQryW5QM3TVmbQU6sqRB5ozYXGAUtZUDNtleoWSc2pUGqoswktfANQ7Uab u76m1mXsFU6hUwIZc4E/86zeSHCFiztoZBU6YdTq1rr06TYGBK+SKcA0GKUk1GCiHy26 Ew== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 33sjn6a6qu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2020 12:03:13 -0400 Received: from m0098409.ppops.net (m0098409.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 08PG3CsO063113; Fri, 25 Sep 2020 12:03:12 -0400 Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 33sjn6a69p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2020 12:03:12 -0400 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 08PG1qCT006904; Fri, 25 Sep 2020 16:02:50 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma04fra.de.ibm.com with ESMTP id 33n9m7ubrj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2020 16:02:49 +0000 Received: from b06wcsmtp001.portsmouth.uk.ibm.com (b06wcsmtp001.portsmouth.uk.ibm.com [9.149.105.160]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 08PG2lhj33882460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2020 16:02:47 GMT Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0A03EA405B; Fri, 25 Sep 2020 16:02:47 +0000 (GMT) Received: from b06wcsmtp001.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9381CA405C; Fri, 25 Sep 2020 16:02:46 +0000 (GMT) Received: from oc3016276355.ibm.com (unknown [9.145.49.151]) by b06wcsmtp001.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2020 16:02:46 +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 Subject: [PATCH v1 2/4] s390x: pv: implement routine to share/unshare memory Date: Fri, 25 Sep 2020 18:02:42 +0200 Message-Id: <1601049764-11784-3-git-send-email-pmorel@linux.ibm.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601049764-11784-1-git-send-email-pmorel@linux.ibm.com> References: <1601049764-11784-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.235,18.0.687 definitions=2020-09-25_14:2020-09-24,2020-09-25 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 spamscore=0 priorityscore=1501 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 malwarescore=0 impostorscore=0 mlxscore=0 suspectscore=1 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009250111 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 --- lib/s390x/asm/uv.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/lib/s390x/asm/uv.h b/lib/s390x/asm/uv.h index 4c2fc48..19019e4 100644 --- a/lib/s390x/asm/uv.h +++ b/lib/s390x/asm/uv.h @@ -71,4 +71,37 @@ 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 + }; + + uv_call(0, (u64)&uvcb); + return uvcb.header.rc; +} + +/* + * 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 -- 2.25.1