From nobody Wed May 1 04:56:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516711110510438.71416742995655; Tue, 23 Jan 2018 04:38:30 -0800 (PST) Received: from localhost ([::1]:55816 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edxqO-0000yQ-OT for importer@patchew.org; Tue, 23 Jan 2018 07:38:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edxoi-0008PQ-IE for qemu-devel@nongnu.org; Tue, 23 Jan 2018 07:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edxoe-0003nU-NL for qemu-devel@nongnu.org; Tue, 23 Jan 2018 07:36:44 -0500 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:40148) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edxoe-0003n4-Gu for qemu-devel@nongnu.org; Tue, 23 Jan 2018 07:36:40 -0500 Received: by mail-wm0-x241.google.com with SMTP id v123so1567019wmd.5 for ; Tue, 23 Jan 2018 04:36:40 -0800 (PST) Received: from localhost.localdomain (bzq-230-168-31-226.red.bezeqint.net. [31.168.230.226]) by smtp.gmail.com with ESMTPSA id r68sm9144889wmd.47.2018.01.23.04.36.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jan 2018 04:36:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veertu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bsdXiqZfHUr7kacGzPatv+Sbz97KAeEueMdkhg3rhI0=; b=s+t2ZEuoBeZEEMim59SmFzROIQNyZgJT4O6l7zxiUgMSLvil85WgnsUjbh8t2S3kLn 2B12troqy4oZfPE1fsI6KAJrQwRBTIaH4J3rXTLOe0G1Bap5XmowsOh4uGqb+Jfshcy+ f8n4f0zRSe8l7Wc0WntVKmyuSJ66tTf1y2opVLxDyYlxOf+Jmhimn7gULU4lP6YgZXld Y7mIqGPBDkWihp1WnrVFUGk8butJ4NnIZPnkVzfSU6rynwV885sSGEgge8l8Ifhi991t XoonQT/EhK4r4CV1HQfBwO2QQ5ITpMVNFpw1Wr5T65rAsdeWhMRNYJ8MoSMqIa9W5LTt pS5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bsdXiqZfHUr7kacGzPatv+Sbz97KAeEueMdkhg3rhI0=; b=iJ4YxDyLSa8LU+ucZQt2rLDd8Ep0576lC2e+y4lgzxlHkkEItbXlCMyfR5t2g1lIKH lki/K7j0gM+Fxqoqmt5uiD+JzmuQ2PvocF5eH/MywUTc224fFmH7P2up9hiiML+T43He Ng4PYtdgApAJxaKFor0T987n0rwaaQ1UnnyROBcFnqwiiqYndPPMv1qCYr9zPDEDjyIy 0FqbwzFL7ykps2Hx6pfr8IR8v7rCl0DawYGIFGAu7PpVhXRf4qEWuO4gfbTHnfVIksj8 svUuKPWnEYSP13vDez8uO9I4+6b2NHT1ks0f+aOw5VLq/9pFt21FhwHOnSV7uxUgUsoy lhmQ== X-Gm-Message-State: AKwxytdcERaE40m0f2V7hrFg+rwiGQoWvidU/UhamqMWrenTUUY2CFlM zyLO4qrqzjnzMvo5tq/TjkrAOi8G X-Google-Smtp-Source: AH8x225wXu7yY8Q48TrNzudigM5OqIk9KEQ2daKXn0tjTaRGWiQ2kzfoRYnXfhBg/lubo+z/KjBv7A== X-Received: by 10.28.130.72 with SMTP id e69mr1865935wmd.50.1516710999047; Tue, 23 Jan 2018 04:36:39 -0800 (PST) From: Izik Eidus To: qemu-devel@nongnu.org Date: Tue, 23 Jan 2018 14:36:38 +0200 Message-Id: <20180123123639.35255-2-izik@veertu.com> X-Mailer: git-send-email 2.13.6 (Apple Git-96) In-Reply-To: <20180123123639.35255-1-izik@veertu.com> References: <20180123123639.35255-1-izik@veertu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH 1/2] Add missing hvdos public domain attribution: X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Izik Eidus Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" hvf.c and vmx.h contain code from hvdos.c that is released as public domain: from hvdos github: https://github.com/mist64/hvdos "License See LICENSE.txt (2-clause-BSD). In order to simplify use of this code as a template, you can consider any p= arts from "hvdos.c" and "interface.h" as being in the public domain." Signed-off-by: Izik Eidus --- target/i386/hvf/hvf.c | 3 +++ target/i386/hvf/vmx.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index 010866ed22..ab4820c3f5 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -17,6 +17,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see . + * + * This file contain code under public domain from the hvdos project: + * https://github.com/mist64/hvdos */ #include "qemu/osdep.h" #include "qemu-common.h" diff --git a/target/i386/hvf/vmx.h b/target/i386/hvf/vmx.h index 9dfcd2f2eb..162a7d51ae 100644 --- a/target/i386/hvf/vmx.h +++ b/target/i386/hvf/vmx.h @@ -17,6 +17,9 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this program; if not, see . + * + * This file contain code under public domain from the hvdos project: + * https://github.com/mist64/hvdos */ =20 #ifndef VMX_H --=20 2.13.6 (Apple Git-96) From nobody Wed May 1 04:56:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1516711111012664.8277214413982; Tue, 23 Jan 2018 04:38:31 -0800 (PST) Received: from localhost ([::1]:55810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edxqM-0000v4-D8 for importer@patchew.org; Tue, 23 Jan 2018 07:38:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1edxoi-0008PR-Ie for qemu-devel@nongnu.org; Tue, 23 Jan 2018 07:36:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1edxog-0003o2-2G for qemu-devel@nongnu.org; Tue, 23 Jan 2018 07:36:44 -0500 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]:37292) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1edxof-0003nc-PF for qemu-devel@nongnu.org; Tue, 23 Jan 2018 07:36:42 -0500 Received: by mail-wm0-x244.google.com with SMTP id v71so1598714wmv.2 for ; Tue, 23 Jan 2018 04:36:41 -0800 (PST) Received: from localhost.localdomain (bzq-230-168-31-226.red.bezeqint.net. [31.168.230.226]) by smtp.gmail.com with ESMTPSA id r68sm9144889wmd.47.2018.01.23.04.36.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jan 2018 04:36:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=veertu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AiPD/L5R54dVdWc2WDr773XbkzmnAgJLyjVMeY+3FRw=; b=YiNU0ry13OFX+kqc8Wo7IquiOiIEzCbG/YnjwshZ9FuGPuVWTlwUFhTAIrWlf8okuy jc5BUlSgMfiP8xRcVnPSToVtaR3LJUxEqXjQT+Lo73VHF7QqNkdr6Znorol8yMwW/jQL +P/92LLc8SNWVHkzhKb8g7X7gXx0i7JYR6RHK47Z1YPdi9k88OPpceTGqY1tCPQTypvK 42EETkMAe7zbVfRWQfsY5WK21hvQnfRrMjK/cNvo+QdIcUOZ+wVz8lb44OfRGSdMqb7P uQpz3XtPUdNFwXDaso/Cc0dlEzHJYVMzrtr+dwbsQ78K61A2ky5m7iHeMAizBgEy5ueo t4FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AiPD/L5R54dVdWc2WDr773XbkzmnAgJLyjVMeY+3FRw=; b=gEoGYiK5cxH0zlMy28q0XBw09eSA+ecBaU7OpcYZPPpOCu1dE5y2dKdzfTt0oQRCnq MKB6ZtqrwZft8pznNKTcfkaD/VAk2k/6lLin28sx+8um2XfUK5o6Hfet1JuN/HWugNt1 p+PctCFjNNBjX+W2FMD0s6hL3Klz82Rp1jBNIYXGj8V1I+nOX2VUk89zwhnp8nWgTZHs RBLc6DUIpI6hXK90iAHc3rWDRsNezZjGdkP9fO82R3iGH+ewmBfYTvnKF6gbd/QSnxu4 CQngsAb4RL25gcOlkxaeDeEDzNLG/IhHIP3hd2rjUe5pYgogyWEwUK1d0DmaDLfCcxIt krNA== X-Gm-Message-State: AKwxytdE3aAW/TrF3P7XJp18Pu8kB1AIlRVshHxQ6FevCYSp6F0UdjwH YjLWa9ZTsfe7hWuOAuQvHBIgT2wV X-Google-Smtp-Source: AH8x224+7HgYlke11W6MF+ujKsc/xzSGIGLZO45CP2aMP061qZw2Sf7XsgSehmIy+EdIFz+eLPVdcw== X-Received: by 10.28.129.70 with SMTP id c67mr1941040wmd.160.1516711000485; Tue, 23 Jan 2018 04:36:40 -0800 (PST) From: Izik Eidus To: qemu-devel@nongnu.org Date: Tue, 23 Jan 2018 14:36:39 +0200 Message-Id: <20180123123639.35255-3-izik@veertu.com> X-Mailer: git-send-email 2.13.6 (Apple Git-96) In-Reply-To: <20180123123639.35255-1-izik@veertu.com> References: <20180123123639.35255-1-izik@veertu.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::244 Subject: [Qemu-devel] [PATCH 2/2] ept_emulation_fault() need NetApp BSD attribution: X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Izik Eidus Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Moving it to a new file and add the BSD license there. Signed-off-by: Izik Eidus --- target/i386/hvf/ept_fault.h | 70 +++++++++++++++++++++++++++++++++++++++++= ++++ target/i386/hvf/hvf.c | 38 +----------------------- 2 files changed, 71 insertions(+), 37 deletions(-) create mode 100644 target/i386/hvf/ept_fault.h diff --git a/target/i386/hvf/ept_fault.h b/target/i386/hvf/ept_fault.h new file mode 100644 index 0000000000..c2938d2bd4 --- /dev/null +++ b/target/i386/hvf/ept_fault.h @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2011 NetApp, Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURP= OSE + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENT= IAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STR= ICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY W= AY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef EPT_FAULT_H +#define EPT_FAULT_H + +#include "hvf-i386.h" + +static inline bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint6= 4_t ept_qual) +{ + int read, write; + + /* EPT fault on an instruction fetch doesn't make sense here */ + if (ept_qual & EPT_VIOLATION_INST_FETCH) { + return false; + } + + /* EPT fault must be a read fault or a write fault */ + read =3D ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; + write =3D ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; + if ((read | write) =3D=3D 0) { + return false; + } + + if (write && slot) { + if (slot->flags & HVF_SLOT_LOG) { + memory_region_set_dirty(slot->region, gpa - slot->start, 1); + hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, + HV_MEMORY_READ | HV_MEMORY_WRITE); + } + } + + /* + * The EPT violation must have been caused by accessing a + * guest-physical address that is a translation of a guest-linear + * address. + */ + if ((ept_qual & EPT_VIOLATION_GLA_VALID) =3D=3D 0 || + (ept_qual & EPT_VIOLATION_XLAT_VALID) =3D=3D 0) { + return false; + } + + return !slot; +} + + +#endif diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c index ab4820c3f5..94d8d119d5 100644 --- a/target/i386/hvf/hvf.c +++ b/target/i386/hvf/hvf.c @@ -36,6 +36,7 @@ #include "x86_emu.h" #include "x86_task.h" #include "x86hvf.h" +#include "ept_fault.h" =20 #include #include @@ -292,43 +293,6 @@ void hvf_cpu_synchronize_post_init(CPUState *cpu_state) run_on_cpu(cpu_state, _hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); } =20 -static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t ept= _qual) -{ - int read, write; - - /* EPT fault on an instruction fetch doesn't make sense here */ - if (ept_qual & EPT_VIOLATION_INST_FETCH) { - return false; - } - - /* EPT fault must be a read fault or a write fault */ - read =3D ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; - write =3D ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; - if ((read | write) =3D=3D 0) { - return false; - } - - if (write && slot) { - if (slot->flags & HVF_SLOT_LOG) { - memory_region_set_dirty(slot->region, gpa - slot->start, 1); - hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, - HV_MEMORY_READ | HV_MEMORY_WRITE); - } - } - - /* - * The EPT violation must have been caused by accessing a - * guest-physical address that is a translation of a guest-linear - * address. - */ - if ((ept_qual & EPT_VIOLATION_GLA_VALID) =3D=3D 0 || - (ept_qual & EPT_VIOLATION_XLAT_VALID) =3D=3D 0) { - return false; - } - - return !slot; -} - static void hvf_set_dirty_tracking(MemoryRegionSection *section, bool on) { hvf_slot *slot; --=20 2.13.6 (Apple Git-96)