From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754369AbcIAADM convert rfc822-to-8bit (ORCPT ); Wed, 31 Aug 2016 20:03:12 -0400 Received: from LGEAMRELO11.lge.com ([156.147.23.51]:40072 "EHLO lgeamrelo11.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753364AbcIAADK (ORCPT ); Wed, 31 Aug 2016 20:03:10 -0400 X-Original-SENDERIP: 156.147.1.126 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 165.244.98.204 X-Original-MAILFROM: namhyung@kernel.org X-Original-SENDERIP: 10.177.227.17 X-Original-MAILFROM: namhyung@kernel.org Date: Thu, 1 Sep 2016 09:03:06 +0900 From: Namhyung Kim To: "Michael S. Tsirkin" CC: , , , , LKML , Paolo Bonzini , Radim =?utf-8?B?S3LEjW3DocWZ?= , Anthony Liguori , Anton Vorontsov , Colin Cross , Kees Cook , Tony Luck , Steven Rostedt , Ingo Molnar , Minchan Kim , Will Deacon Subject: Re: [PATCH 1/3] virtio: Basic implementation of virtio pstore driver Message-ID: <20160901000306.GA9510@sejong> References: <20160831080802.13408-1-namhyung@kernel.org> <20160831080802.13408-2-namhyung@kernel.org> <20160831175007-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 In-Reply-To: <20160831175007-mutt-send-email-mst@kernel.org> User-Agent: Mutt/1.7.0 (2016-08-17) X-MIMETrack: Itemize by SMTP Server on LGEKRMHUB07/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/09/01 09:03:07, Serialize by Router on LGEKRMHUB07/LGE/LG Group(Release 8.5.3FP6|November 21, 2013) at 2016/09/01 09:03:07 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michael, On Wed, Aug 31, 2016 at 05:54:04PM +0300, Michael S. Tsirkin wrote: > On Wed, Aug 31, 2016 at 05:08:00PM +0900, Namhyung Kim wrote: > > The virtio pstore driver provides interface to the pstore subsystem so > > that the guest kernel's log/dump message can be saved on the host > > machine. Users can access the log file directly on the host, or on the > > guest at the next boot using pstore filesystem. It currently deals with > > kernel log (printk) buffer only, but we can extend it to have other > > information (like ftrace dump) later. > > > > It supports legacy PCI device using single order-2 page buffer. It uses > > two virtqueues - one for (sync) read and another for (async) write. > > Since it cannot wait for write finished, it supports up to 128 > > concurrent IO. The buffer size is configurable now. > > > > Cc: Paolo Bonzini > > Cc: Radim Krčmář > > Cc: "Michael S. Tsirkin" > > Cc: Anthony Liguori > > Cc: Anton Vorontsov > > Cc: Colin Cross > > Cc: Kees Cook > > Cc: Tony Luck > > Cc: Steven Rostedt > > Cc: Ingo Molnar > > Cc: Minchan Kim > > Cc: Will Deacon > > Cc: kvm@vger.kernel.org > > Cc: qemu-devel@nongnu.org > > Cc: virtualization@lists.linux-foundation.org > > Cc: virtio-dev@lists.oasis-open.org > > Signed-off-by: Namhyung Kim > > --- [SNIP] > > +#define TYPE_TABLE_ENTRY(_entry) \ > > + { PSTORE_TYPE_##_entry, VIRTIO_PSTORE_TYPE_##_entry } > > + > > +struct type_table { > > + int pstore; > > + u16 virtio; > > +} type_table[] = { > > + TYPE_TABLE_ENTRY(DMESG), > > +}; > > + > > +#undef TYPE_TABLE_ENTRY > > + > > + > > +static u16 to_virtio_type(struct virtio_pstore *vps, enum pstore_type_id type) > > +{ > > + unsigned int i; > > + > > + for (i = 0; i < ARRAY_SIZE(type_table); i++) { > > + if (type == type_table[i].pstore) > > + return cpu_to_virtio16(vps->vdev, type_table[i].virtio); > > Does this pass sparse checks? If yes I'm surprised - this clearly > returns a virtio16 type. Ah, didn't run sparse. Will change it to return a __le16 type (according to your comment below). > > > > + } > > + > > + return cpu_to_virtio16(vps->vdev, VIRTIO_PSTORE_TYPE_UNKNOWN); > > +} > > + > > +static enum pstore_type_id from_virtio_type(struct virtio_pstore *vps, u16 type) This one should be '__le16 type' as well. > > +{ > > + unsigned int i; > > + > > + for (i = 0; i < ARRAY_SIZE(type_table); i++) { > > + if (virtio16_to_cpu(vps->vdev, type) == type_table[i].virtio) > > + return type_table[i].pstore; > > + } > > + > > + return PSTORE_TYPE_UNKNOWN; > > +} > > + [SNIP] > > + > > +struct virtio_pstore_req { > > + __virtio16 cmd; > > + __virtio16 type; > > + __virtio32 flags; > > + __virtio64 id; > > + __virtio32 count; > > + __virtio32 reserved; > > +}; > > + > > +struct virtio_pstore_res { > > + __virtio16 cmd; > > + __virtio16 type; > > + __virtio32 ret; > > +}; > > Is there a reason to support legacy endian-ness? > If not, you can just use __le formats. I just didn't know what's the preferred type. Will change! Thanks, Namhyung > > > > +struct virtio_pstore_fileinfo { > > + __virtio64 id; > > + __virtio32 count; > > + __virtio16 type; > > + __virtio16 unused; > > + __virtio32 flags; > > + __virtio32 len; > > + __virtio64 time_sec; > > + __virtio32 time_nsec; > > + __virtio32 reserved; > > +}; > > + > > +struct virtio_pstore_config { > > + __virtio32 bufsize; > > +}; > > + > > +#endif /* _LINUX_VIRTIO_PSTORE_H */ > > -- > > 2.9.3