Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/814277/?format=api
{ "id": 814277, "url": "http://patchwork.ozlabs.org/api/patches/814277/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150548138021.5945.4408791416827487125.stgit@bahia.lan/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<150548138021.5945.4408791416827487125.stgit@bahia.lan>", "list_archive_url": null, "date": "2017-09-15T13:16:20", "name": "[4/4] ppc/kvm: generalize the use of kvmppc_get_htab_fd()", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "28cee8123eee647367e5e5f17b6050ee1184af30", "submitter": { "id": 69178, "url": "http://patchwork.ozlabs.org/api/people/69178/?format=api", "name": "Greg Kurz", "email": "groug@kaod.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/150548138021.5945.4408791416827487125.stgit@bahia.lan/mbox/", "series": [ { "id": 3310, "url": "http://patchwork.ozlabs.org/api/series/3310/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=3310", "date": "2017-09-15T13:15:33", "name": "ppc/kvm: htab fd code improvements", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3310/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/814277/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/814277/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@bilbo.ozlabs.org", "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=nongnu.org\n\t(client-ip=2001:4830:134:3::11; helo=lists.gnu.org;\n\tenvelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11])\n\t(using TLSv1 with cipher AES256-SHA (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xtwy64Qxbz9sRm\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri, 15 Sep 2017 23:20:46 +1000 (AEST)", "from localhost ([::1]:53377 helo=lists.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.71) (envelope-from\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>)\n\tid 1dsqY0-0006fU-Ob\n\tfor incoming@patchwork.ozlabs.org; Fri, 15 Sep 2017 09:20:44 -0400", "from eggs.gnu.org ([2001:4830:134:3::10]:42209)\n\tby lists.gnu.org with esmtp (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1dsqTu-0002uv-5Y\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 09:16:31 -0400", "from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)\n\t(envelope-from <groug@kaod.org>) id 1dsqTq-0003zc-2b\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 09:16:30 -0400", "from 3.mo2.mail-out.ovh.net ([46.105.58.226]:54022)\n\tby eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)\n\t(Exim 4.71) (envelope-from <groug@kaod.org>) id 1dsqTp-0003zJ-PV\n\tfor qemu-devel@nongnu.org; Fri, 15 Sep 2017 09:16:25 -0400", "from player770.ha.ovh.net (b6.ovh.net [213.186.33.56])\n\tby mo2.mail-out.ovh.net (Postfix) with ESMTP id D2BE0AA04F\n\tfor <qemu-devel@nongnu.org>; Fri, 15 Sep 2017 15:16:24 +0200 (CEST)", "from bahia.lan (gar31-1-82-66-74-139.fbx.proxad.net [82.66.74.139])\n\t(Authenticated sender: groug@kaod.org)\n\tby player770.ha.ovh.net (Postfix) with ESMTPA id 6E4BD3C008B;\n\tFri, 15 Sep 2017 15:16:20 +0200 (CEST)" ], "From": "Greg Kurz <groug@kaod.org>", "To": "qemu-devel@nongnu.org", "Date": "Fri, 15 Sep 2017 15:16:20 +0200", "Message-ID": "<150548138021.5945.4408791416827487125.stgit@bahia.lan>", "In-Reply-To": "<150548133297.5945.7401220081077343726.stgit@bahia.lan>", "References": "<150548133297.5945.7401220081077343726.stgit@bahia.lan>", "User-Agent": "StGit/0.17.1-46-g6855-dirty", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "X-Ovh-Tracer-Id": "15179382547778345461", "X-VR-SPAMSTATE": "OK", "X-VR-SPAMSCORE": "-100", "X-VR-SPAMCAUSE": "gggruggvucftvghtrhhoucdtuddrfeelledrgeekgdeifecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd", "X-detected-operating-system": "by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic]\n\t[fuzzy]", "X-Received-From": "46.105.58.226", "Subject": "[Qemu-devel] [PATCH 4/4] ppc/kvm: generalize the use of\n\tkvmppc_get_htab_fd()", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.21", "Precedence": "list", "List-Id": "<qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<http://lists.nongnu.org/archive/html/qemu-devel/>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n\t<mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Cc": "Alexey Kardashevskiy <aik@ozlabs.ru>, Thomas Huth <thuth@redhat.com>,\n\tqemu-ppc@nongnu.org, David Gibson <david@gibson.dropbear.id.au>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "\"Qemu-devel\"\n\t<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>" }, "content": "The use of KVM_PPC_GET_HTAB_FD is open-coded in kvmppc_read_hptes()\nand kvmppc_write_hpte().\n\nThis patch modifies kvmppc_get_htab_fd() so that it can be used\neverywhere we need to access the in-kernel htab:\n- add an index argument\n => only kvmppc_read_hptes() passes an actual index, all other users\n pass 0\n- add an errp argument to propagate error messages to the caller.\n => spapr migration code prints the error\n => hpte helpers pass &error_abort to keep the current behavior\n of hw_error()\n\nWhile here, this also fixes a bug in kvmppc_write_hpte() so that it\nopens the htab fd for writing instead of reading as it currently does.\nThis never broke anything because we currently never call this code,\nas explained in the changelog of commit c1385933804bb:\n\n\"This support updating htab managed by the hypervisor. Currently\n we don't have any user for this feature. This actually bring the\n store_hpte interface in-line with the load_hpte one. We may want\n to use this when we want to emulate henter hcall in qemu for HV\n kvm.\"\n\nThe above is still true today.\n\nSigned-off-by: Greg Kurz <groug@kaod.org>\n---\n hw/ppc/spapr.c | 15 +++++++--------\n target/ppc/kvm.c | 27 +++++++++------------------\n target/ppc/kvm_ppc.h | 4 ++--\n 3 files changed, 18 insertions(+), 28 deletions(-)", "diff": "diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c\nindex 1ae79326d1ac..eeef549fbc15 100644\n--- a/hw/ppc/spapr.c\n+++ b/hw/ppc/spapr.c\n@@ -1211,14 +1211,15 @@ static uint64_t spapr_get_patbe(PPCVirtualHypervisor *vhyp)\n */\n static int get_htab_fd(sPAPRMachineState *spapr)\n {\n+ Error *local_err = NULL;\n+\n if (spapr->htab_fd >= 0) {\n return spapr->htab_fd;\n }\n \n- spapr->htab_fd = kvmppc_get_htab_fd(false);\n+ spapr->htab_fd = kvmppc_get_htab_fd(false, 0, &local_err);\n if (spapr->htab_fd < 0) {\n- error_report(\"Unable to open fd for reading hash table from KVM: %s\",\n- strerror(spapr->htab_fd));\n+ error_report_err(local_err);\n }\n \n return spapr->htab_fd;\n@@ -1931,6 +1932,7 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id)\n sPAPRMachineState *spapr = opaque;\n uint32_t section_hdr;\n int fd = -1;\n+ Error *local_err = NULL;\n \n if (version_id < 1 || version_id > 1) {\n error_report(\"htab_load() bad version\");\n@@ -1945,8 +1947,6 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id)\n }\n \n if (section_hdr) {\n- Error *local_err = NULL;\n-\n /* First section gives the htab size */\n spapr_reallocate_hpt(spapr, section_hdr, &local_err);\n if (local_err) {\n@@ -1959,10 +1959,9 @@ static int htab_load(QEMUFile *f, void *opaque, int version_id)\n if (!spapr->htab) {\n assert(kvm_enabled());\n \n- fd = kvmppc_get_htab_fd(true);\n+ fd = kvmppc_get_htab_fd(true, 0, &local_err);\n if (fd < 0) {\n- error_report(\"Unable to open fd to restore KVM hash table: %s\",\n- strerror(fd));\n+ error_report_err(local_err);\n return fd;\n }\n }\ndiff --git a/target/ppc/kvm.c b/target/ppc/kvm.c\nindex 09d7dea79e2d..c37d74941085 100644\n--- a/target/ppc/kvm.c\n+++ b/target/ppc/kvm.c\n@@ -2550,21 +2550,25 @@ int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function)\n return kvm_vm_ioctl(kvm_state, KVM_PPC_RTAS_DEFINE_TOKEN, &args);\n }\n \n-int kvmppc_get_htab_fd(bool write)\n+int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp)\n {\n struct kvm_get_htab_fd s = {\n .flags = write ? KVM_GET_HTAB_WRITE : 0,\n- .start_index = 0,\n+ .start_index = index,\n };\n int ret;\n \n if (!cap_htab_fd) {\n- fprintf(stderr, \"KVM version doesn't support saving the hash table\\n\");\n+ error_setg(errp, \"KVM version doesn't support %s the HPT\",\n+ write ? \"writing\" : \"reading\");\n return -ENOTSUP;\n }\n \n ret = kvm_vm_ioctl(kvm_state, KVM_PPC_GET_HTAB_FD, &s);\n if (ret < 0) {\n+ error_setg(errp, \"Unable to open fd for %s HPT %s KVM: %s\",\n+ write ? \"writing\" : \"reading\", write ? \"to\" : \"from\",\n+ strerror(errno));\n return -errno;\n }\n \n@@ -2648,17 +2652,10 @@ void kvm_arch_init_irq_routing(KVMState *s)\n \n void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n)\n {\n- struct kvm_get_htab_fd ghf = {\n- .flags = 0,\n- .start_index = ptex,\n- };\n int fd, rc;\n int i;\n \n- fd = kvm_vm_ioctl(kvm_state, KVM_PPC_GET_HTAB_FD, &ghf);\n- if (fd < 0) {\n- hw_error(\"kvmppc_read_hptes: Unable to open HPT fd\");\n- }\n+ fd = kvmppc_get_htab_fd(false, ptex, &error_abort);\n \n i = 0;\n while (i < n) {\n@@ -2700,19 +2697,13 @@ void kvmppc_read_hptes(ppc_hash_pte64_t *hptes, hwaddr ptex, int n)\n void kvmppc_write_hpte(hwaddr ptex, uint64_t pte0, uint64_t pte1)\n {\n int fd, rc;\n- struct kvm_get_htab_fd ghf;\n struct {\n struct kvm_get_htab_header hdr;\n uint64_t pte0;\n uint64_t pte1;\n } buf;\n \n- ghf.flags = 0;\n- ghf.start_index = 0; /* Ignored */\n- fd = kvm_vm_ioctl(kvm_state, KVM_PPC_GET_HTAB_FD, &ghf);\n- if (fd < 0) {\n- hw_error(\"kvmppc_write_hpte: Unable to open HPT fd\");\n- }\n+ fd = kvmppc_get_htab_fd(true, 0 /* Ignored */, &error_abort);\n \n buf.hdr.n_valid = 1;\n buf.hdr.n_invalid = 0;\ndiff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h\nindex 08aab46c5a56..349f892631bf 100644\n--- a/target/ppc/kvm_ppc.h\n+++ b/target/ppc/kvm_ppc.h\n@@ -51,7 +51,7 @@ uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift);\n #endif /* !CONFIG_USER_ONLY */\n bool kvmppc_has_cap_epr(void);\n int kvmppc_define_rtas_kernel_token(uint32_t token, const char *function);\n-int kvmppc_get_htab_fd(bool write);\n+int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp);\n int kvmppc_save_htab(QEMUFile *f, int fd, size_t bufsize, int64_t max_ns);\n int kvmppc_load_htab_chunk(QEMUFile *f, int fd, uint32_t index,\n uint16_t n_valid, uint16_t n_invalid);\n@@ -245,7 +245,7 @@ static inline int kvmppc_define_rtas_kernel_token(uint32_t token,\n return -1;\n }\n \n-static inline int kvmppc_get_htab_fd(bool write)\n+static inline int kvmppc_get_htab_fd(bool write, uint64_t index, Error **errp)\n {\n return -1;\n }\n", "prefixes": [ "4/4" ] }