Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/xen/xen Make these pages non-executable, and style.



details:   https://anonhg.NetBSD.org/src/rev/4bd6bde654a9
branches:  trunk
changeset: 356075:4bd6bde654a9
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Aug 30 16:01:55 2017 +0000

description:
Make these pages non-executable, and style.

diffstat:

 sys/arch/xen/xen/if_xennet_xenbus.c  |  41 ++++++++++++++++++-----------------
 sys/arch/xen/xen/xennetback_xenbus.c |  24 ++++++++------------
 2 files changed, 31 insertions(+), 34 deletions(-)

diffs (295 lines):

diff -r 9980a2429be9 -r 4bd6bde654a9 sys/arch/xen/xen/if_xennet_xenbus.c
--- a/sys/arch/xen/xen/if_xennet_xenbus.c       Wed Aug 30 15:46:19 2017 +0000
+++ b/sys/arch/xen/xen/if_xennet_xenbus.c       Wed Aug 30 16:01:55 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: if_xennet_xenbus.c,v 1.70 2017/03/04 19:11:01 bouyer Exp $      */
+/*      $NetBSD: if_xennet_xenbus.c,v 1.71 2017/08/30 16:01:55 maxv Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -22,7 +22,6 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
  */
 
 /*
@@ -85,7 +84,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.70 2017/03/04 19:11:01 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.71 2017/08/30 16:01:55 maxv Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -135,7 +134,7 @@
 #undef XENNET_DEBUG
 #ifdef XENNET_DEBUG
 #define XEDB_FOLLOW     0x01
-#define XEDB_INIT       0x02 
+#define XEDB_INIT       0x02
 #define XEDB_EVENT      0x04
 #define XEDB_MBUF       0x08
 #define XEDB_MEM        0x10
@@ -147,6 +146,8 @@
 #define DPRINTFN(n,x)
 #endif
 
+extern pt_entry_t xpmap_pg_nx;
+
 #define GRANT_INVALID_REF -1 /* entry is free */
 
 #define NET_TX_RING_SIZE __CONST_RING_SIZE(netif_tx, PAGE_SIZE)
@@ -200,7 +201,7 @@
        unsigned long sc_rx_feature;
 #define FEATURE_RX_FLIP                0
 #define FEATURE_RX_COPY                1
-       krndsource_t     sc_rnd_source;
+       krndsource_t sc_rnd_source;
 };
 #define SC_NLIVEREQ(sc) ((sc)->sc_rx_ring.req_prod_pvt - \
                            (sc)->sc_rx_ring.sring->rsp_prod)
@@ -310,7 +311,6 @@
                    "xnfrx", NULL, IPL_VM, NULL, NULL, NULL);
                if_xennetrxbuf_cache_inited = 1;
        }
-               
 
        /* initialize free RX and RX request lists */
        mutex_init(&sc->sc_tx_lock, MUTEX_DEFAULT, IPL_NET);
@@ -438,7 +438,7 @@
                    UVM_KMF_WIRED);
        }
        splx(s1);
-               
+
        ether_ifdetach(ifp);
        if_detach(ifp);
 
@@ -626,7 +626,7 @@
                tsleep(xennet_xenbus_suspend, PRIBIO, "xnet_suspend", hz/2);
                xennet_handler(sc);
        }
-       
+
        /*
         * dom0 may still use references to the grants we gave away
         * earlier during RX buffers allocation. So we do not free RX buffers
@@ -790,7 +790,7 @@
        multicall_entry_t mcl[2];
 
        mutex_enter(&sc->sc_rx_lock);
-       
+
        DPRINTF(("%s: xennet_free_rx_buffer\n", device_xname(sc->sc_dev)));
        /* get back memory from RX ring */
        for (i = 0; i < NET_RX_RING_SIZE; i++) {
@@ -840,8 +840,8 @@
                                /* remap the page */
                                mmu[0].ptr = (ma << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
                                mmu[0].val = pa >> PAGE_SHIFT;
-                               MULTI_update_va_mapping(&mcl[0], va, 
-                                   (ma << PAGE_SHIFT) | PG_V | PG_KW,
+                               MULTI_update_va_mapping(&mcl[0], va,
+                                   (ma << PAGE_SHIFT) | PG_V | PG_KW | xpmap_pg_nx,
                                    UVMF_TLB_FLUSH|UVMF_ALL);
                                xpmap_ptom_map(pa, ptoa(ma));
                                mcl[1].op = __HYPERVISOR_mmu_update;
@@ -883,7 +883,7 @@
 xennet_rx_free_req(struct xennet_rxreq *req)
 {
        struct xennet_xenbus_softc *sc = req->rxreq_sc;
-       
+
        KASSERT(mutex_owned(&sc->sc_rx_lock));
 
        /* puts back the RX request in the list of free RX requests */
@@ -895,7 +895,7 @@
         * RX buffers to catch-up with backend's consumption
         */
        req->rxreq_gntref = GRANT_INVALID_REF;
-       
+
        if (sc->sc_free_rxreql >= (NET_RX_RING_SIZE * 4 / 5) &&
            __predict_true(sc->sc_backend_status == BEST_CONNECTED)) {
                xennet_alloc_rx_buffer(sc);
@@ -945,7 +945,7 @@
 
        sc->sc_tx_ring.rsp_cons = resp_prod;
        /* set new event and check for race with rsp_cons update */
-       sc->sc_tx_ring.sring->rsp_event = 
+       sc->sc_tx_ring.sring->rsp_event =
            resp_prod + ((sc->sc_tx_ring.sring->req_prod - resp_prod) >> 1) + 1;
        ifp->if_timer = 0;
        xen_wmb();
@@ -1032,13 +1032,14 @@
 
                pa = req->rxreq_pa;
                va = req->rxreq_va;
-               
+
                if (sc->sc_rx_feature == FEATURE_RX_FLIP) {
                        /* remap the page */
                        mmu[0].ptr = (ma << PAGE_SHIFT) | MMU_MACHPHYS_UPDATE;
                        mmu[0].val = pa >> PAGE_SHIFT;
-                       MULTI_update_va_mapping(&mcl[0], va, 
-                           (ma << PAGE_SHIFT) | PG_V | PG_KW, UVMF_TLB_FLUSH|UVMF_ALL);
+                       MULTI_update_va_mapping(&mcl[0], va,
+                           (ma << PAGE_SHIFT) | PG_V | PG_KW | xpmap_pg_nx,
+                           UVMF_TLB_FLUSH|UVMF_ALL);
                        xpmap_ptom_map(pa, ptoa(ma));
                        mcl[1].op = __HYPERVISOR_mmu_update;
                        mcl[1].args[0] = (unsigned long)mmu;
@@ -1116,14 +1117,14 @@
        sc->sc_rx_ring.rsp_cons = i;
        RING_FINAL_CHECK_FOR_RESPONSES(&sc->sc_rx_ring, more_to_do);
        mutex_exit(&sc->sc_rx_lock);
-       
+
        if (more_to_do)
                goto again;
 
        return 1;
 }
 
-/* 
+/*
  * The output routine of a xennet interface
  * Called at splnet.
  */
@@ -1469,7 +1470,7 @@
                        for(j=0; j<16; j++)
                                printf("%c", pkt[i-15+j]>=32 &&
                                    pkt[i-15+j]<127?pkt[i-15+j]:'.');
-                       printf("%c\n%c%c%c%c%c%c%c%c  ", '|', 
+                       printf("%c\n%c%c%c%c%c%c%c%c  ", '|',
                            XCHR((i+1)>>28), XCHR((i+1)>>24),
                            XCHR((i+1)>>20), XCHR((i+1)>>16),
                            XCHR((i+1)>>12), XCHR((i+1)>>8),
diff -r 9980a2429be9 -r 4bd6bde654a9 sys/arch/xen/xen/xennetback_xenbus.c
--- a/sys/arch/xen/xen/xennetback_xenbus.c      Wed Aug 30 15:46:19 2017 +0000
+++ b/sys/arch/xen/xen/xennetback_xenbus.c      Wed Aug 30 16:01:55 2017 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xennetback_xenbus.c,v 1.58 2016/12/15 09:28:04 ozaki-r Exp $      */
+/*      $NetBSD: xennetback_xenbus.c,v 1.59 2017/08/30 16:01:55 maxv Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -22,11 +22,10 @@
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.58 2016/12/15 09:28:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xennetback_xenbus.c,v 1.59 2017/08/30 16:01:55 maxv Exp $");
 
 #include "opt_xen.h"
 
@@ -54,7 +53,6 @@
 
 #include <net/if_ether.h>
 
-
 #include <xen/xen.h>
 #include <xen/xen_shm.h>
 #include <xen/evtchn.h>
@@ -69,6 +67,8 @@
 #define XENPRINTF(x)
 #endif
 
+extern pt_entry_t xpmap_pg_nx;
+
 #define NET_TX_RING_SIZE __RING_SIZE((netif_tx_sring_t *)0, PAGE_SIZE)
 #define NET_RX_RING_SIZE __RING_SIZE((netif_rx_sring_t *)0, PAGE_SIZE)
 
@@ -648,7 +648,6 @@
        return NULL;
 }
 
-
 /* get a page to remplace a mbuf cluster page given to a domain */
 static int
 xennetback_get_mcl_page(paddr_t *map)
@@ -664,7 +663,6 @@
        *map = ((paddr_t)mcl_pages[mcl_pages_alloc]) << PAGE_SHIFT;
        mcl_pages_alloc--;
        return 0;
-       
 }
 
 static void
@@ -795,7 +793,7 @@
                XENPRINTF(("%s pkt offset %d size %d id %d req_cons %d\n",
                    xneti->xni_if.if_xname, txreq.offset,
                    txreq.size, txreq.id, MASK_NETIF_TX_IDX(req_cons)));
-               
+
                pkt = pool_get(&xni_pkt_pool, PR_NOWAIT);
                if (__predict_false(pkt == NULL)) {
                        static struct timeval lasttime;
@@ -818,7 +816,7 @@
                        m_freem(m);
                        continue;
                }
-                       
+
                if (__predict_false(err)) {
                        printf("%s: mapping foreing page failed: %d\n",
                            xneti->xni_if.if_xname, err);
@@ -889,7 +887,7 @@
                        }
                }
                m_set_rcvif(m, ifp);
-               
+
                if_percpuq_enqueue(ifp->if_percpuq, m);
        }
        xen_rmb(); /* be sure to read the request before updating pointer */
@@ -1062,7 +1060,7 @@
                         */
                        xpmap_ptom_map(xmit_pa, newp_ma);
                        MULTI_update_va_mapping(mclp, xmit_va,
-                           newp_ma | PG_V | PG_RW | PG_U | PG_M, 0);
+                           newp_ma | PG_V | PG_RW | PG_U | PG_M | xpmap_pg_nx, 0);
                        mclp++;
                        gop->mfn = xmit_ma >> PAGE_SHIFT;
                        gop->domid = xneti->xni_domid;
@@ -1144,7 +1142,7 @@
                                        rxresp->status = NETIF_RSP_ERROR;
                                }
                        }
-                                       
+
                        /* update pointer */
                        KASSERT(
                            xneti->xni_rxring.rsp_prod_pvt + i == resp_prod);
@@ -1378,7 +1376,7 @@
                                        rxresp->status = NETIF_RSP_ERROR;
                                }
                        }
-                                       
+
                        /* update pointer */
                        KASSERT(
                            xneti->xni_rxring.rsp_prod_pvt + i == resp_prod);
@@ -1414,7 +1412,6 @@
        splx(s);
 }
 
-
 static void
 xennetback_ifwatchdog(struct ifnet * ifp)
 {
@@ -1429,7 +1426,6 @@
        xennetback_ifstart(ifp);
 }
 
-
 static int
 xennetback_ifinit(struct ifnet *ifp)
 {



Home | Main Index | Thread Index | Old Index