qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: P J P <ppandit@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: Yang Hongke <yanghongke@huawei.com>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] net: ne2000: check ring buffer control registers
Date: Tue, 23 Feb 2016 13:58:08 +0530 (IST)	[thread overview]
Message-ID: <alpine.LFD.2.20.1602231042380.31193@wniryva> (raw)
In-Reply-To: <56CBD1AF.6090802@redhat.com>

   Hello Jason,

+-- On Tue, 23 Feb 2016, Jason Wang wrote --+
| I mean with your patch, driver will only be allowed to set EN0_STOPPG
| before EN0_STARTPG. So if a driver want to set STARTPG first, the check
| 
| +            if (v < NE2000_PMEM_END && v < s->stop) {
| 
| will prevent the driver from working correctly since s->stop is zero here.

  Before drivers could start using NIC, it'll be initialised from its ROM, 
right? Which would set the PSTART & PSTOP registers to the default values. 
With '-net nic,model=ne2k_pci,vlan=0' I see,

    s->start = 19456, s->stop = 32768

| >   I think any attempts to define the ring buffer limits should reset 
| > 'boundary' and 'curpag' registers to s->start(STARTPG). I wonder if a 
| > driver should be allowed to fiddle with the ring buffers location inside 
| > contorller's memory. It does not seem right.
| 
| Well, I think we could not assume the behavior of a driver, especially
| consider it may be malicious.

  Yes; That's why it'll help to keep drivers from fiddling with the ring 
buffer dimensions. IIUC, there is an upper limit to where PSTOP could 
point[1],

  "In 8 bit mode the PSTOP register should not exceed to 0x60,
    in 16 bit mode the PSTOP register should not exceed to 0x80"

[1] http://www.ethernut.de/pdf/8019asds.pdf

Kernel drivers too seem to have it fixed
  -> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/8390/ne.c#n398
  -> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/ethernet/8390/ne2k-pci.c#n342

| >   Check if (s->start == s->stop) at each receive call?
| Or in ne2000_buffer_full()?

  ne2000_buffer_full() too assumes that 's->stop > s->start'

    ...
    avail = (s->stop - s->start) - (index - boundary);

Is there a case wherein drivers need to adjust ring buffer pointers? If not, I 
think it's better to convert EN0_STARTPG:, EN0_STOPPG:, EN0_BOUNDARY: and 
EN1_CURPAG: cases into no-ops.

--
 - P J P
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F

  reply	other threads:[~2016-02-23  8:28 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02 14:29 [Qemu-devel] [PATCH] net: ne2000: check ring buffer control registers P J P
2016-02-05  9:04 ` Jason Wang
2016-02-05  9:29   ` [Qemu-devel] 答复: " yanghongke
2016-02-09  6:49     ` P J P
2016-02-09  6:47   ` [Qemu-devel] " P J P
2016-02-15  4:25     ` P J P
2016-02-23  3:27     ` Jason Wang
2016-02-23  8:28       ` P J P [this message]
2016-02-24  1:52         ` Jason Wang
2016-02-24  5:58           ` P J P

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LFD.2.20.1602231042380.31193@wniryva \
    --to=ppandit@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yanghongke@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).